Exemple #1
0
int
main( int argc, char *argv[] )
{
     DFBResult       ret;
     int             i;
     VoodooPlayInfo  info;
     VoodooPlayer   *player = NULL;

     /* Initialize DirectFB including command line parsing. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          DirectFBError( "DirectFBInit() failed", ret );
          return -1;
     }

     /* Parse the command line. */
     if (!parse_command_line( argc, argv ))
          return -2;

     if (m_name) {
          direct_snputs( info.name, m_name, VOODOO_PLAYER_NAME_LENGTH );
     }

     ret = voodoo_player_create( m_name ? &info : NULL, &player );
     if (ret) {
          D_ERROR( "Voodoo/Play: Could not create the player (%s)!\n", DirectFBErrorString(ret) );
          goto out;
     }


     do {
          voodoo_player_broadcast( player );

          direct_thread_sleep( 100000 );

          voodoo_player_enumerate( player, player_callback, NULL );

          if (m_lookup) {
               for (i=1; i<argc; i++) {
                    char buf[100];

                    if (voodoo_player_lookup( player, (const u8 *)argv[i], NULL, buf, sizeof(buf) )) {
                         D_ERROR( "Voodoo/Play: No '%s' found!\n", argv[i] );
                         continue;
                    }

                    D_INFO( "Voodoo/Play: Found '%s' with address %s\n", argv[i], buf );
               }
          }

          direct_thread_sleep( 2000000 );
     } while (m_run);


out:
     if (player)
          voodoo_player_destroy( player );

     return ret;
}
Exemple #2
0
static void bluetooth_setup(case_t *bt_case)
{
	char command[200];
	char firmware_name[50];
	//mt6620 no need to do anything
	if(!strcmp(bt_case->dev_name, "mt6620"))
	{
		return;
	}
	
	if(!strcmp(bt_case->dev_name, "rtl8723as"))
	{
		sprintf(command, "hciattach -n -s 115200 /dev/%s rtk_h5 &", bt_case->nod_path);
		printf("bt command = %s\n", command);
		pcba_system(command);
		direct_thread_sleep(3000000);
		return;
	}

	if(!strcmp(bt_case->dev_name, "rtl8723bs") 
		|| !strcmp(bt_case->dev_name, "rtl8761") 
		|| !strcmp(bt_case->dev_name, "rtl8723vq0"))
	{
		direct_thread_sleep(3000000);
		sprintf(command, "rtk_hciattach -d %s -n -s 115200 /dev/%s rtk_h5 &", bt_case->dev_name, bt_case->nod_path);
		printf("bt command = %s\n", command);
		pcba_system(command);
		// printf("debug\n");
		direct_thread_sleep(3000000);
		return;
	}
	
	if(!strcmp(bt_case->dev_name, "ap6210") 
		|| !strcmp(bt_case->dev_name, "ap6330") 
		|| !strcmp(bt_case->dev_name, "ap6476"))
	{
		if(!strcmp(bt_case->dev_name, "ap6210"))
		{
			strcpy(firmware_name, "bcm20710a1.hcd");
		}
		else if(!strcmp(bt_case->dev_name, "ap6330"))
		{
			strcpy(firmware_name, "bcm40183b2.hcd");
		}
		else if(!strcmp(bt_case->dev_name, "ap6476"))
		{
			strcpy(firmware_name, "bcm2076b1.hcd");
		}
		
		sprintf(command, "brcm_patchram_plus --enable_hci --no2bytes --tosleep 200000 --baudrate 1000000 --patchram /system/etc/firmware/%s /dev/%s &", firmware_name, bt_case->nod_path);
		printf("uart = %s\n", bt_case->nod_path);

		printf("bt command = %s\n", command);
		
		pcba_system(command);
		direct_thread_sleep(4000000);
	}
	return;
}
Exemple #3
0
static DirectResult
discover_host( VoodooPlayer   *player,
               const char     *address,
               VoodooPlayInfo *ret_info,
               char           *ret_addr,
               int             max_addr )
{
     DirectResult ret;
     int          bc_num  = 5;
     int          bc_wait = 30000;

     voodoo_player_broadcast( player );

     while (bc_num--) {
          direct_thread_sleep( bc_wait );

          bc_wait += bc_wait;

          if (address)
               ret = voodoo_player_lookup_by_address( player, address, ret_info );
          else
               ret = voodoo_player_lookup( player, NULL, ret_info, ret_addr, max_addr );

          if (ret == DR_OK)
               break;

          voodoo_player_broadcast( player );
     }

     return ret;
}
Exemple #4
0
void
direct_trap( const char *domain, int sig )
{
     sigval_t val;

     if (direct_config->delay_trap_ms) {
          D_LOG( Direct_Trap, VERBOSE, "NOT RAISING signal %d from %s, waiting for %dms... attach gdb --pid=%d\n", sig, domain, direct_config->delay_trap_ms, getpid() );
          direct_thread_sleep( direct_config->delay_trap_ms * 1000LL );
          return;
     }

     D_LOG( Direct_Trap, VERBOSE, "Raising signal %d from %s...\n", sig, domain );

     val.sival_int = direct_gettid();

#ifndef DIRECT_BUILD_NO_SIGQUEUE
     sigqueue( direct_gettid(), sig, val );
#endif
//     direct_tgkill( direct_getpid(), direct_gettid(), sig );

     D_LOG( Direct_Trap, VERBOSE, "...tgkill(%d) on ourself returned, maybe blocked, calling abort()!\n", sig );

     abort();

     D_LOG( Direct_Trap, VERBOSE, "...abort() returned as well, calling %s()!\n",
#ifdef __NR_exit_group
            "exit_group" );

     syscall( __NR_exit_group, DR_BUG );
#else
            "_exit" );

            _exit( DR_BUG );
#endif
}
int
main( int argc, char *argv[] )
{
     int                    i;
     DFBResult              ret;
     IDirectFB             *dfb;
     IDirectFBDisplayLayer *layer  = NULL;
     App                    apps[1];
     DFBDisplayLayerConfig  config;

     /* Parse arguments. */
     for (i=1; i<argc; i++) {
          if (!strcmp( argv[i], "-h" ))
               return show_usage( argv[0] );
     }

     /* Initialize DirectFB. */
     ret = DirectFBInit( &argc, &argv );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: DirectFBInit() failed!\n" );
          return ret;
     }

     /* Create super interface. */
     ret = DirectFBCreate( &dfb );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: DirectFBCreate() failed!\n" );
          return ret;
     }

     /* Get primary layer. */
     ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFB::GetDisplayLayer( PRIMARY ) failed!\n" );
          goto out;
     }

     
     layer->GetConfiguration( layer, &config );

     app_init( &apps[0], layer, 100, 50, config.width-300, config.height-150, 0 );

     while (true) {
          direct_thread_sleep( 1000000 );

          app_update( &apps[0] );
     }


out:
     /* Shutdown DirectFB. */
     dfb->Release( dfb );

     return ret;
}
Exemple #6
0
static void
ShowMessage( unsigned int ms, const char *name, const char *prefix, const char *format, ... )
{
    char buf[512];

    va_list ap;

    va_start( ap, format );

    vsnprintf( buf, sizeof(buf), format, ap );

    va_end( ap );

    direct_log_printf( NULL, "%s [[ %-30s ]]  %s\n", prefix, name, buf );

    direct_thread_sleep( ms * 1000 );
}
Exemple #7
0
static ssize_t
Read( VoodooLink *link,
      void       *buffer,
      size_t      count )
{
     Link *l = link->priv;

     while (true) {
          ssize_t        ret;
          fd_set         rfds;
          struct timeval tv;
          int            retval;

          FD_ZERO( &rfds );
          FD_SET( l->socket, &rfds );

          tv.tv_sec  = 0;
          tv.tv_usec = 0;//10000;

          direct_mutex_lock( &l->lock );

          retval = select( l->socket+1, &rfds, NULL, NULL, &tv );
          switch (retval) {
               default:
                    ret = recv( l->socket, buffer, count, 0 );
                    direct_mutex_unlock( &l->lock );
                    return ret;

               case 0:
                    D_DEBUG( "Voodoo/Link: Timeout during select()\n" );
                    break;

               case -1:
                    //if (errno && errno != EINTR)
                    D_PERROR( "Voodoo/Player: select() on socket failed!\n" );
                    direct_mutex_unlock( &l->lock );
                    return -1;
          }

          direct_mutex_unlock( &l->lock );

          direct_thread_sleep( 20000 );
     }

     return -1;
}
Exemple #8
0
static DFBResult
Test_Sensitivity( IDirectFB        *dfb,
                  DFBInputDeviceID  device_id )
{
     DFBResult             ret;
     IDirectFBInputDevice *device;
     IDirectFBEventBuffer *buffer;
     int                   i, n;
     int                   sensitivities[] = { 0x100, 0x200, 0x80 };

     D_INFO( "DFBTest/Input: Testing sensitivity with input device %u...\n", device_id );

     ret = dfb->GetInputDevice( dfb, device_id, &device );
     if (ret) {
          D_DERROR( ret, "DFBTest/Input: GetInputDevice( %u ) failed!\n", device_id );
          return ret;
     }

     ret = device->CreateEventBuffer( device, &buffer );
     if (ret) {
          D_DERROR( ret, "DFBTest/Input: CreateEventBuffer() failed!\n" );
          device->Release( device );
          return ret;
     }

     for (i=0; i<D_ARRAY_SIZE(sensitivities); i++) {
          DFBInputDeviceConfig config;
          unsigned int         move = 0;

          D_INFO( "DFBTest/Input: Setting sensitivity to 0x%x, please move mouse!\n", sensitivities[i] );

          config.flags       = DIDCONF_SENSITIVITY;
          config.sensitivity = sensitivities[i];

          ret = device->SetConfiguration( device, &config );
          if (ret) {
               D_DERROR( ret, "DFBTest/Input: SetConfiguration() failed!\n" );
               buffer->Release( buffer );
               device->Release( device );
               return ret;
          }

          buffer->Reset( buffer );

          for (n=0; n<500; n++) {
               DFBInputEvent event;

               buffer->WaitForEvent( buffer );

               buffer->GetEvent( buffer, DFB_EVENT(&event) );

               switch (event.type) {
                    case DIET_AXISMOTION:
                         if (event.flags & DIEF_AXISREL) {
                              //D_INFO( "DFBTest/Input: Motion (axis %d) by %d\n", event.axis, event.axisrel );

                              if (event.axisrel > 0)
                                   move += event.axisrel;
                              else
                                   move -= event.axisrel;
                         }

                         break;

                    default:
                         break;
               }
          }

          D_INFO( "DFBTest/Input: Average movement %d.\n", move / n );

          direct_thread_sleep( 1000000 );
     }

     buffer->Release( buffer );
     device->Release( device );

     return DFB_OK;
}
Exemple #9
0
DFBResult
dfb_core_destroy( CoreDFB *core, bool emergency )
{
     D_MAGIC_ASSERT( core, CoreDFB );
     D_ASSERT( core->refs > 0 );
     D_ASSERT( core == core_dfb );

     D_DEBUG_AT( DirectFB_Core, "%s...\n", __FUNCTION__ );

     if (!emergency) {
          pthread_mutex_lock( &core_dfb_lock );

          if (--core->refs) {
               pthread_mutex_unlock( &core_dfb_lock );
               return DFB_OK;
          }
     }

     dfb_font_manager_destroy( core->font_manager );

     if (core->signal_handler)
          direct_signal_handler_remove( core->signal_handler );
     
     if (core->cleanup_handler)
          direct_cleanup_handler_remove( core->cleanup_handler );

     if (core->master) {
          if (emergency) {
               fusion_kill( core->world, 0, SIGKILL, 1000 );
          }
          else {
               fusion_kill( core->world, 0, SIGTERM, 5000 );
               fusion_kill( core->world, 0, SIGKILL, 2000 );
          }
     }

     dfb_core_process_cleanups( core, emergency );

     while (fusion_arena_exit( core->arena, dfb_core_arena_shutdown,
                               core->master ? NULL : dfb_core_arena_leave,
                               core, emergency, NULL ) == DR_BUSY)
     {
          D_ONCE( "waiting for DirectFB slaves to terminate" );
          direct_thread_sleep( 100000 );
     }

     fusion_exit( core->world, emergency );

     if (!emergency)
          direct_thread_remove_init_handler( core->init_handler );

     D_MAGIC_CLEAR( core );

     D_FREE( core );
     core_dfb = NULL;

     if (!emergency) {
          pthread_mutex_unlock( &core_dfb_lock );

          direct_shutdown();
     }

     return DFB_OK;
}
Exemple #10
0
int
main( int argc, char *argv[] )
{
    DFBResult              ret;
    int                    i;
    IDirectFB             *dfb;
    IDirectFBDisplayLayer *layer;

    /* Initialize DirectFB including command line parsing. */
    ret = DirectFBInit( &argc, &argv );
    if (ret) {
        DirectFBError( "DirectFBInit() failed", ret );
        return -1;
    }

    /* Parse the command line. */
    if (!parse_command_line( argc, argv ))
        return -2;

    SHOW_INFO( "Starting up..." );

    /* Create the super interface. */
    ret = DirectFBCreate( &dfb );
    if (ret) {
        DirectFBError( "DirectFBCreate() failed", ret );
        return -3;
    }

    /* Get the primary layer interface. */
    ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );
    if (ret) {
        D_DERROR( ret, "IDirectFB::GetDisplayLayer() failed!\n" );
        dfb->Release( dfb );
        return -4;
    }


    if (!m_toplevel_id)
        RunTest( Test_CreateWindow, "CreateWindow", layer, NULL );

    RunTest( Test_CreateSubWindow, "CreateSubWindow", layer, NULL );


    for (i=0; i<D_ARRAY_SIZE(m_tests); i++) {
        if (m_tests[i].run_top)
            RunTest( m_tests[i].func, m_tests[i].name, layer, NULL );

        if (m_tests[i].run_sub)
            RunTest( m_tests[i].func, m_tests[i].name, layer, (void*) (unsigned long) m_subwindow_id );
    }

    while (m_wait_at_end)
        direct_thread_sleep( 1000000 );

    SHOW_INFO( "Shutting down..." );

    /* Release the sub window. */
    if (m_subwindow)
        m_subwindow->Release( m_subwindow );

    /* Release the top level. */
    if (m_toplevel)
        m_toplevel->Release( m_toplevel );

    /* Release the layer. */
    layer->Release( layer );

    /* Release the super interface. */
    dfb->Release( dfb );

    return EXIT_SUCCESS;
}
Exemple #11
0
bool test_rtc(case_t *rtc_case)
{
	int fd = -1;
	int ret = -1;
	struct rtc_time rtc;
	struct tm sys_clock;
	time_t tmp_time;
	struct timeval tv;
	
	char rtc_hardware[50] = "/sys/class/rtc/rtc0/ext_osc";
	
	ret = cat_file(rtc_hardware);
	if(1 != ret)
		return false;

	fd = open("/dev/rtc0", O_RDWR);
	if(!fd)
	{
		printf("open rtc device error\n");
		return false;
	}

	sscanf(rtc_case->nod_path, "%d-%d-%d %d:%d:%d", &rtc.tm_year, &rtc.tm_mon, &rtc.tm_mday,&rtc.tm_hour, &rtc.tm_min, &rtc.tm_sec);

	rtc.tm_year -= 1900;
	rtc.tm_mon -= 1;
	printf("\nCurrentRTC data/time is %d-%d-%d, %02d:%02d:%02d.\n", rtc.tm_mday, rtc.tm_mon + 1,rtc.tm_year + 1900, rtc.tm_hour, rtc.tm_min, rtc.tm_sec);
	ret = ioctl(fd, RTC_SET_TIME, &rtc);
	if(-1 == ret)
	{
		printf("set rtc device error\n");
		printf("errno = %d\n", errno);
		return false;
	}
	direct_thread_sleep(5000000); 		// modified wait more time for rtc to set time
	ret = ioctl(fd, RTC_RD_TIME, &rtc);
	if(-1 == ret)
	{
		printf("read rtc device error\n");
		return false;
	}
	printf("\nCurrentRTC data/time is %d-%d-%d, %02d:%02d:%02d.\n", rtc.tm_mday, rtc.tm_mon + 1,rtc.tm_year + 1900, rtc.tm_hour, rtc.tm_min, rtc.tm_sec);
	sys_clock.tm_sec = rtc.tm_sec;
    sys_clock.tm_min = rtc.tm_min;
    sys_clock.tm_hour = rtc.tm_hour;
    sys_clock.tm_mday = rtc.tm_mday;
    sys_clock.tm_mon = rtc.tm_mon;
    sys_clock.tm_year = rtc.tm_year;

	tmp_time = mktime(&sys_clock);

	tv.tv_sec = tmp_time;
    tv.tv_usec = 0;
    if(settimeofday(&tv, NULL) < 0)
    {
		printf("Set system datatime error!\n");
		printf("errno = %d\n", errno);
		return false;
	}
	
	direct_thread_sleep(4000000);
	
	ret = ioctl(fd, RTC_RD_TIME, &rtc);
	if(-1 == ret)
	{
		printf("read rtc device error\n");
		return false;
	}
	
	if(gettimeofday(&tv, NULL) < 0)
    {
		printf("get system datatime error!\n");
		printf("errno = %d\n", errno);
		return false;
	}
	
	if(!compare_time(rtc, tv))
	{
		printf("rtc != linux time\n");
		return false;
	}
	else
	{
		sprintf(rtc_case->pass_string, "%s(%d-%d-%d, %02d:%02d:%02d)",rtc_case->pass_string, rtc.tm_mday, rtc.tm_mon + 1,rtc.tm_year + 1900, rtc.tm_hour, rtc.tm_min, rtc.tm_sec);
	}
	return true;

}
Exemple #12
0
bool test_wifi(case_t *wifi_case)
{
	int ret, count = 0;
	char iwlist_command[100] = "iwlist wlan0 scan > /tmp.wifi";
	char result[100];
	char result_name[100];
	int limit_dbm, real_dbm;

	//wait wifi up
	direct_thread_sleep(2000000);
	do
	{
		direct_thread_sleep(1000000);
		
		if(!pcba_system(iwlist_command))
		{
			count++;
			continue;
		}
		
		if(strlen(wifi_case->dev_name) != 0)
		{
			strcpy(result_name, wifi_case->dev_name);
			sprintf(iwlist_command, "grep %s /tmp.wifi -A 100 > /tmp.wifi2", result_name);
			printf("new command = %s\n", iwlist_command);
			pcba_system(iwlist_command);
			if(is_file_empty("/tmp.wifi2"))
			{
				printf("can't find essid %s\n", result_name);
				return false;
			}
			pcba_system("cat /tmp.wifi2 > /tmp.wifi");
		}
		else
		{
			//get wifi name
			if(!pcba_system("cat /tmp.wifi  | grep \"ESSID\" | head -1 > /tmp.wifi.name"))
			{
				count++;
				continue;
			}
			ret = cat_file_s("/tmp.wifi.name", result);
			if(!ret)
			{
				count++;
				continue;
			}
			//ESSID:"Actions_CSRD_ESS"
			sscanf(result,"%*[^\"]\"%[^\"]\"", result_name);
		}
		//get wifi signal level
		if(!pcba_system("cat /tmp.wifi | grep level | head -1 | grep -o [-][0-9]*[0-9] | head -1 > /tmp.wifi.level"))
		{
			count++;
			continue;
		}
		ret = cat_file_s("/tmp.wifi.level", result);
		if(!ret)
		{
			count++;
			continue;
		}
		if(strlen(wifi_case->nod_path) != 0)
		{
			limit_dbm = atoi(wifi_case->nod_path);
			real_dbm = atoi(result);
			printf("limit dbm = %d, real dbm = %d\n", limit_dbm, real_dbm);
			if(real_dbm < limit_dbm)
				return false;
		}
		sprintf(wifi_case->pass_string, "%s(%sdbm:%s)",wifi_case->pass_string, result, result_name);
		return true;
	}while(count < 10);

	printf("wifi cant find any ap in 10s\n");
	return false;
}
static DFBResult
app_init( App                   *app,
          IDirectFBDisplayLayer *layer,
          int                    x,
          int                    y,
          int                    width,
          int                    height,
          int                    index )
{
     DFBResult             ret;
     DFBWindowDescription  desc;
     IDirectFBWindow      *window;
     IDirectFBSurface     *surface;

     desc.flags  = DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_CAPS;
     desc.width  = width;
     desc.height = height;
     desc.posx   = x;
     desc.posy   = y;
     desc.caps   = DWCAPS_NONE; //| DWCAPS_ALPHACHANNEL | DWCAPS_DOUBLEBUFFER;

     /* Create a surface for the image. */
     ret = layer->CreateWindow( layer, &desc, &window );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFBDisplayLayer::CreateWindow() failed!\n" );
          return ret;
     }

     /* Get the surface. */
     ret = window->GetSurface( window, &surface );
     if (ret) {
          D_DERROR( ret, "DFBTest/WindowFlip: IDirectFBWindow::GetSurface() failed!\n" );
          return ret;
     }

     surface->Clear( surface, 0xff, 0xff, 0xff, 0xff );

     surface->Flip( surface, NULL, DSFLIP_NONE );


     direct_thread_sleep( 2000000 );
     D_INFO( "Showing window...\n" );
     direct_thread_sleep( 500000 );

     window->SetOpacity( window, 0xff );

     direct_thread_sleep( 500000 );
     D_INFO( "Done.\n" );
     direct_thread_sleep( 1000000 );

     app->window       = window;
     app->surface      = surface;
     app->index        = index;
     app->resolution.w = width;
     app->resolution.h = height;

     app->anim_dirx    = 5;
     app->anim_diry    = 5;
     app->anim_x       = 0;
     app->anim_y       = 0;

     return DFB_OK;
}
Exemple #14
0
bool test_pc(case_t *pc_case)
{
	int drv_on = 0;
	int ret;
	while(true)
	{
		ret = cat_file(pc_case->nod_path);
		if(ret == -1)
			return false;
		if(ret)
		{
			draw_result(pc_case, true);
			if(!drv_on)
			{
				if (!strcmp(pc_case->dev_name, "7059"))
				{
					pcba_system("echo 0 > /sys/class/android_usb/android0/enable");
					pcba_system("echo mass_storage > /sys/class/android_usb/android0/functions");
					pcba_system("echo 1 > /sys/class/android_usb/android0/enable");
				}
				else if (!strcmp(pc_case->dev_name, "7021"))
				{
					if(!insmod_drv("udc", "", 1))
						return false;
					if(!insmod_drv("g_android", "", 1))
						return false;
					pcba_system("echo 0 > /sys/class/android_usb/android0/enable");
					pcba_system("echo mass_storage > /sys/class/android_usb/android0/functions");
					pcba_system("echo 1 > /sys/class/android_usb/android0/enable");
				}
				else if (!strcmp(pc_case->dev_name, "9009"))
				{
					if(!insmod_drv("libcomposite", "", 1))
						return false;
					if(!insmod_drv("u_serial", "", 1))
						return false;
					if(!insmod_drv("usb_f_acm", "", 1))
						return false;
					if(!insmod_drv("g_android", "", 1))
						return false;
					pcba_system("echo 0 > /sys/class/android_usb/android0/enable");
					pcba_system("echo 10d6 > /sys/class/android_usb/android0/idVendor");
					pcba_system("echo 0c02> /sys/class/android_usb/android0/idProduct");
					pcba_system("echo mass_storage > /sys/class/android_usb/android0/functions");
					pcba_system("echo 1 > /sys/class/android_usb/android0/enable");
					//pcba_system("echo /dev/actk > /sys/class/android_usb/f_mass_storage/lun0/file");
				}
				else
				{
					if(!insmod_drv("dwc3", "", 1))
						return false;
					if(!insmod_drv("dwc3-actions", "", 1))
						return false;
					if(!insmod_drv("g_android", "", 1))
						return false;
					pcba_system("echo 0 > /sys/class/android_usb/android0/enable");
					pcba_system("echo mass_storage > /sys/class/android_usb/android0/functions");
					pcba_system("echo 1 > /sys/class/android_usb/android0/enable");
				}
				drv_on = 1;
			}
		}
		else
		{
			if(drv_on)
			{
				if (!strcmp(pc_case->dev_name, "7059"))
				{
					; //do nothing
				}
				else if (!strcmp(pc_case->dev_name, "7021"))
				{
					if(!insmod_drv("g_android", "", 0))
						return false;
					if(!insmod_drv("udc", "", 0))
						return false;
				}
				else if (!strcmp(pc_case->dev_name, "9009"))
				{
					/*if(!insmod_drv("g_android", "", 0))
						return false;
					if(!insmod_drv("usb_f_acm", "", 0))
						return false;
					if(!insmod_drv("u_serial", "", 0))
						return false;
					if(!insmod_drv("libcomposite", "", 0))
						return false;*/
				}
				else
				{
					if(!insmod_drv("g_android", "", 0))
						return false;
					if(!insmod_drv("dwc3-actions", "", 0))
						return false;
					if(!insmod_drv("dwc3", "", 0))
						return false;
				}
				drv_on = 0;
			}
		}
		direct_thread_sleep(1000000);
	}
}
Exemple #15
0
static void *handle_record_button(DirectThread *thread, void *arg)
{
	IDirectFBSurface *surface = arg;
	IDirectFBFont 		*font, *font_s;
	DFBFontDescription 	font_desc;
	bool local_flg = false;
	int width, height;
	int font_big_height, font_little_height;
	
	char font_file[50] = "/misc/font/wqy-zenhei.ttc";
	
	DFBCHECK(surface->GetSize(surface, &width, &height));
	
	font_big_height = 48;
	while(font_big_height > (height / 2))
	{
		font_big_height -= 4;
	}
	font_desc.flags = DFDESC_HEIGHT;
	font_desc.height = font_big_height;
	DFBCHECK(dfb->CreateFont( dfb, font_file,  &font_desc, &font));
	
	font_little_height = 32;
	while(font_little_height > (height / 4))
	{
		font_little_height -= 4;
	}
	font_desc.height = font_little_height;
	DFBCHECK(dfb->CreateFont( dfb, font_file,  &font_desc, &font_s));
	
	printf("font size is %d %d\n", font_big_height, font_little_height);
	
	DFBCHECK(surface->SetFont(surface, font_s));
	
	DFBCHECK(surface->SetColor(surface, 0x8C, 0x8C, 0x8C, 0xff));
	DFBCHECK(surface->DrawString(surface, "点击录音", -1, width / 2, 0, DSTF_TOPCENTER));
	
	DFBCHECK(surface->SetColor(surface, 0x41, 0x41, 0x41, 0xff));
	DFBCHECK(surface->DrawString(surface, "测试TP请避开此区域", -1, width / 2, height / 4, DSTF_TOPCENTER));
	
	DFBCHECK(surface->SetFont(surface, font));
	DFBCHECK(surface->SetColor(surface, 0xE3, 0x6C, 0x4C, 0xff));
	DFBCHECK(surface->DrawString(surface, "状态:停止录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
	DFBCHECK(surface->Flip(surface, NULL, 0));
	while(true)
	{
		if(record_flg != local_flg)
		{
			local_flg = record_flg;
			DFBCHECK(surface->SetColor(surface, 0xff, 0xff, 0xff, 0xff));
			DFBCHECK(surface->FillRectangle(surface, 0 , height / 2, width, font_big_height + 4));  //need fix
			DFBCHECK(surface->SetColor(surface, 0xE3, 0x6C, 0x4C, 0xff));
			if(local_flg)
			{
				DFBCHECK(surface->DrawString(surface, "状态:正在录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
			}
			else
			{
				DFBCHECK(surface->DrawString(surface, "状态:停止录音", -1, width / 2, height / 2, DSTF_TOPCENTER));
			}
			DFBCHECK(surface->Flip(surface, NULL, 0));
		}
		direct_thread_sleep(100000);
	}
	
	font->Release(font);
	font_s->Release(font_s);
}
Exemple #16
0
static void * camera_thread(DirectThread *thread, void *arg)
{
	int camera_dev_num = 0;
	int second_dev_num = -1;
	int fid;
	struct stat st;
	bool same_sensor_flg = false;
	char *back = "b";
	char *front = "f";
	int cur_stat = 0;
	int *num = arg;
    int width = camera_pixel_width;
	int height = camera_pixel_height;
    
	printf("camera num = %d\n", *num);
	
	if (0 == stat("/dev/video3", &st))
	{
		printf("got two sensor at video0 video3\n");
		second_dev_num = 3;
	}
#ifndef __GS702C__
	else if (0 == stat("/dev/video1", &st))
	{

		printf("got two sensor at video0 video1\n");
		second_dev_num = 1;
	}
#endif
	if (second_dev_num < 0)
	{
		same_sensor_flg = true;
		printf("got two same sensor\n");
	}

	while(true)
	{
		do
		{
			if(open_camera_device(camera_dev_num, *num) == -1)
			{
				printf("open camera %d error\n", camera_dev_num);
				direct_thread_sleep( 1000000 );
				break;
			}
			if(init_camera_device(&width, &height) == -1)
			{
				printf("init camera %d error\n", camera_dev_num);
				close_camera_device();
				break;
			}
			camera_start_capturing();
			camera_mainloop();
			camera_stop_capturing();
			uninit_camera_device();
			close_camera_device();
		}while(0);
		
		if(same_sensor_flg)
		{
			fid = open("/sys/bus/platform/devices/camera_flag_device.0/front_back", O_WRONLY);
			if(0 == cur_stat)
			{
				write(fid,back,1);
				close(fid);
				cur_stat = 1;
			}
			else
			{
				write(fid,front,1);
				close(fid);
				cur_stat = 0;
			}
		}
		else
		{
			if(camera_dev_num)
			{
				camera_dev_num = 0;
				//printf("switch to video0, the rear camera \n");
			}
			else
			{
				camera_dev_num = second_dev_num;
				printf("switch to video%d, front-facing cameras \n", second_dev_num);
			}
		}
	}
}