Пример #1
0
int main() {
    int fd;
    double time1, time2;
    int i;
    void *buf_ptr = valloc(BUF_SIZE);
    assert(buf_ptr != NULL);

    get_time_offset();

    assert((fd = open("/dev/sda", O_RDONLY|O_DIRECT)) >= 0);
    time1 = get_time();
    for( i = 0; i < 100; i++) {
        //assert(lseek64(fd, rand()% 10737418240, SEEK_SET) > 0);
        assert(lseek64(fd, (rand()% 153741)*BUF_SIZE, SEEK_CUR) >= 0);
        assert(read(fd, buf_ptr, BUF_SIZE) == BUF_SIZE);
    }
    time2 = get_time();

    printf("direct access disk time: %.3f", (time2 - time1)/100);

    close(fd);
    return 0;
}
Пример #2
0
void power_switch(UINT32 mode)
{
	unsigned long keycode;
	SYSTEM_DATA* sys_data;
	UINT32 vkey;
	UINT32 times = 0,display_type=0;
	date_time dt;
	UINT32 hh,mm,ss;
	char time_str[10];
	struct pan_key key_struct;
	UINT32 timer;
	struct sf_panel_attr panel_attr;
/*alfred.wu 1.0版本的MCU程序因为待机时间不能超过256小时*/
#ifdef MCUSTANDBY
	struct sf_panel_time time;
	date_time sRecentTime;	
	UINT32 nDurationTime = 0;
	UINT32 nYear = 0;
	UINT32 nMonth = 0;
	UINT32 nDay = 0;
	UINT32 nHour = 0;
	UINT32 nMin = 0;
	UINT32 nSec = 0;
	struct sf_standby_param standby_param;
	/*Note: For the limited memory size of MCU, if using led panel, the maximum IR key num is 5 and for vfd panel the size is 2. */
	struct sf_power_ir_key ir_key[] = \
		{
#ifdef RC04_A
			{0x007f, 0x1c}, /*RC04_A*/
#endif
#ifdef RC09_A
			{0x00FD, 0x1A}, /*RC09_A*/
#endif
#ifdef RC11_A
			{0x00ff, 0x54}, /*RC11_A*/	
#endif
#ifdef RC19_D
			{0x01fe, 0x00}, /*RC11_A*/	
#endif
#ifdef RC01_A_02
			{0x807f, 0x0a}, /*RC01_A_02*/	
#endif
#ifdef ORDER_GZ1010001
			{0x007f, 0x1c}, /*RC04_A*/
#else
			{0x007f, 0x0a}, /*RC01_A*/
#endif
			{0x01FE, 0x01}, /*REMOTE02420100*/
			{0x06FB, 0x0E}, /*ALI_RCU_60_KEY*/
		};
#endif
	sys_data = sys_data_get();
	sys_data->bstandmode = 1;
	sys_data_save(1);
	system_state = SYS_STATE_POWER_OFF;

/*Archer:The following process is unnessary when using mcu standby resolution.*/
#if 0
	power_off_process();
	power_off_process2();
#endif
#ifndef MCUSTANDBY
    if(mode != 1)
		key_pan_display("off ", 4);
	key_pan_display_standby(1);
	key_pan_display_lock(0);

    api_standby_led_onoff(TRUE);
#else
#if 0
    get_local_time(&dt);
    nDurationTime = api_get_recently_timer();
	POWER_PRINTF("nDurationTime = 0x%x\n",nDurationTime);
	if(0 != nDurationTime)
	{
		sRecentTime.year = YEAR(nDurationTime);
		sRecentTime.month= MONTH(nDurationTime);
		sRecentTime.day= DAY(nDurationTime);
		sRecentTime.hour= HOUR(nDurationTime);
		sRecentTime.min= MIN(nDurationTime);
		sRecentTime.sec= SEC(nDurationTime);

		POWER_PRINTF("RecentTime:%d-%d-%d %d:%d:%d\n",sRecentTime.year,sRecentTime.month,\
							sRecentTime.day, sRecentTime.hour,sRecentTime.min,sRecentTime.sec);
		
		get_time_offset(&dt,&sRecentTime,&nDay,&nHour,&nMin,&nSec);
		//standby_param.standby_time_sec = nHour*60*60+nMin*60;
		standby_param.standby_time_sec = 60;
		POWER_PRINTF("standby:hour:%d, minute:%d, total secs:%d\n",nHour,nMin, standby_param.standby_time_sec);
		//pan_set_standby_time((struct pan_device*)dev_get_by_id(HLD_DEV_TYPE_PAN,0),&sPanelTime);
	}
	else
	{
		POWER_PRINTF("no timer\n");
	}
#endif

	//pan_display(g_pan_dev, "        ", 8);//albert.li del 2011.1.25
	
	/*albert.li add 2011.1.25*/
	get_local_time(&dt);
	time.hour = dt.hour;
	time.min= dt.min;
	time.sec = dt.sec;
#ifndef FAKE_STANDBY	

	sf_panel_clear();
	reset_sf_panel_all_led();
	/*albert.li add end*/

	sf_panel_display_time(&time);

	sf_panel_term();
#else	
	pan_io_control(g_pan_dev, PAN_DRIVER_GET_ATTRIBUTE, &panel_attr);
	if (panel_attr.type == SF_PANEL_TYPE_LED)
	{
		pan_display(g_pan_dev,"OFF ", 4);
	}
	else
	{
		pan_display(g_pan_dev,"STANDBY", 7);
	}
#endif	
	power_off_process();
	//S5PanelStandby(g_pan_dev,(const)&sPanIRSpecialKey,2);//guop edit
	standby_param.ir_key_num = sizeof(ir_key)/sizeof(struct sf_power_ir_key);
	standby_param.ir_key_list = ir_key;
	standby_param.standby_time_sec = 0;
#ifndef FAKE_STANDBY
	sf_power_down(&standby_param);
#else	 //zhouxp fake standby
	{
		while (1)
		{
			ControlMsg_t msg;
			times++;
			times = times % 100; 
			osal_delay(5000);
						
			vkey = V_KEY_NULL;
			if(key_get_key(&key_struct,0))
			{
				keycode = scan_code_to_msg_code(&key_struct);
				ap_hk_to_vk(0, keycode, &vkey);
			}
			else
				keycode = PAN_KEY_INVALID;
			if(vkey == V_KEY_POWER)
			{
				power_on_process();
			}
			ap_receive_msg( &msg, 10);
			libc_printf("got msg type=%d\n",msg.msgType);
			if(msg.msgType== CTRL_MSG_SUBTYPE_CMD_TIMER_WAKEUP)
				power_on_process();
				
		}
	}
#endif		

#endif
#ifndef MCUSTANDBY
	if(1)	/* Real Standby*//*alfred.wu ali的IC真待机处理流程在MCUSTANDBY后不会执行*/
	{
		UINT32	cur_time, target_time;

		get_local_time(&dt);
		pan_close(g_pan_dev);
        timer = api_get_recently_timer();
		// disable interrupt
		osal_interrupt_disable();

		cur_time = (dt.sec & 0x3F ) | ((dt.min & 0x3F )<<6)  | ((dt.hour & 0x1F )<<12) | ((dt.day & 0x1F)<<17)
			| ((dt.month & 0xF) << 22) | (((dt.year % 100) & 0x3F)<<26);

		sys_ic_enter_standby(timer, cur_time);
		// enable interrupt
		osal_interrupt_enable();
	}	
    
     
    while (1)
    {
		times++;
		times = times % 100; 
		osal_delay(5000);
    				
		if(times==0)
		{
			//get_cur_time(&hh,&mm,&ss);
			get_local_time(&dt);
			hh = dt.hour;
			mm = dt.min;

			if(display_type==0)
			    sprintf(time_str,"%02d%02d ",hh,mm);
			else
				sprintf(time_str,"%02d.%02d",hh,mm);

			key_pan_display(time_str, 5);
			display_type++;
			display_type %= 2;
		}
		
		vkey = V_KEY_NULL;
		if(key_get_key(&key_struct,0))
		{
			keycode = scan_code_to_msg_code(&key_struct);
			ap_hk_to_vk(0, keycode, &vkey);
		}
		else
			keycode = PAN_KEY_INVALID;
		if(vkey == V_KEY_POWER)
		{
			power_on_process();
		}
	}
#endif	
}
Пример #3
0
INT32 win_progname_set_info(void)
{
	UINT16 group_name[MAX_SERVICE_NAME_LENGTH + 1+10];
	UINT8 group_type, av_mode;

	UINT16 cur_channel;
	P_NODE p_node;
	S_NODE s_node;
	char string[100];
	char prog_name[MAX_SERVICE_NAME_LENGTH + 1];
	INT32 ret, len;
	UINT32 i, j;
	UINT16 icon;
	date_time dt;
	eit_event_info_t *pe = NULL,  *fe = NULL;
	UINT8 *s1 = NULL,  *s2 = NULL;
	INT32 strlen;
	struct ACTIVE_SERVICE_INFO service;
	UINT8 *src;
    UINT8 *src8;
	date_time start_time, end_time, local_time;
	INT32 day, h, m, sec, timeLen, timePassed, progProcessLen;

	UINT32 fav_mask;

	struct t_ttx_lang *ttx_lang_list;
	UINT8 ttx_lang_num;
	struct t_subt_lang* sub_lang_list;
	UINT8 sub_lang_num;
	fav_mask = 0;
	for (i = 0; i < MAX_FAVGROUP_NUM; i++)
		fav_mask |= (0x01 << i);

	get_STC_offset(&h, &m, &sec);

	av_mode = sys_data_get_cur_chan_mode();
	cur_channel = sys_data_get_cur_group_cur_mode_channel();
	ret = get_prog_at(cur_channel, &p_node);
	if(ret != SUCCESS)
		return -1;
	get_sat_by_id(p_node.sat_id, &s_node);
	get_cur_group_name((char*)group_name, &group_type);
	get_local_time(&dt);
	service.tp_id = p_node.tp_id;
	service.service_id = p_node.prog_number;
	epg_set_active_service(&service, 1);

	/* Get current next epg info */
	pe = epg_get_cur_service_event((INT32)cur_channel, PRESENT_EVENT, NULL, NULL, NULL, event_update);
	fe = epg_get_cur_service_event((INT32)cur_channel, FOLLOWING_EVENT, NULL, NULL, NULL, FALSE);
	s1 = (UINT8*)epg_get_event_name(pe, present_name, 32);
	s2 = (UINT8*)epg_get_event_name(fe, following_name, 32);

	#ifdef TTX_ON
	TTXEng_GetInitLang(&ttx_lang_list, &ttx_lang_num);
	#endif
	#ifdef SUBTITLE_ON
	subt_get_language(&sub_lang_list ,&sub_lang_num);
	#endif
	#ifdef TTX_ON
	if(sub_lang_num == 0)
		TTXEng_GetSubtLang(&ttx_lang_list,&sub_lang_num);
	#endif
	/* Set bmp content */
	if (av_mode == TV_CHAN)
		icon = IM_PAY;
	else
		icon = IM_INFORMATION_RADIO;
	OSD_SetBitmapContent(&prog_bmp, icon);
	#ifdef TTX_ON
	if(ttx_lang_num>0)
		icon = IM_INFORMATION_ICON_TTX;
	else
		icon = INVALID_ID; 
	//soc_printf("ttx icon id:%x, ", icon);
	OSD_SetBitmapContent(&prog_name_ttx, icon);
	//OSD_SetRect(&bmp->head.frame, p_prog_bmp->left, p_prog_bmp->top, p_prog_bmp->width,p_prog_bmp->height);
	OSD_DrawObject( (OBJECT_HEAD*) (&prog_name_ttx), C_UPDATE_ALL);
	#endif
	

	#ifdef SUBTITLE_ON
	if(sub_lang_num>0)
		icon = IM_INFORMATION_ICON_SUBTITLE;
	else 
		icon = INVALID_ID;
	//soc_printf("subt icon id:%x\n", icon);
	OSD_SetBitmapContent(&prog_name_subt, icon);
	OSD_DrawObject( (OBJECT_HEAD*) (&prog_name_subt), C_UPDATE_ALL);
	#endif

	/* Init display strings */
	for (i=0; i<7; i++)
		MEMSET(display_strs[20+i], 0, 2*MAX_DISP_STR_LEN);

	/* Set prog_name content */
	MEMSET(string, 0, sizeof(string));
	if (p_node.ca_mode == 0)
		STRCPY(string, "");
	else
		STRCPY(string, "$");

	ComAscStr2Uni(string, display_strs[20]);
	strlen = ComUniStrLen(display_strs[20]);
	ComUniStrCopyChar((UINT8*) &display_strs[20][strlen], p_node.service_name);

	/* Set prog_time content */
	MEMSET(string, 0, sizeof(string));
	sprintf(string, "%4d.%02d.%02d ", dt.year, dt.month, dt.day);
	ComAscStr2Uni(string, display_strs[21]);
	strlen = ComUniStrLen(display_strs[21]);
	src = OSD_GetUnicodeString(weekday_id[dt.weekday%7]);
	ComUniStrCopyChar((UINT8*) &display_strs[21][strlen], src);

	/* Set prog_num content */
	MEMSET(string, 0, sizeof(string));
	sprintf(string, "%03d", cur_channel + 1);
	ComAscStr2Uni(string, display_strs[22]);

	/* Set epg_time_now, epg_now, prog_process content */
	if (s1)
	{
		MEMSET(string, 0, sizeof(string));
		get_STC_offset(&h, &m, &sec);
		get_event_start_time(pe, &start_time);
		get_event_end_time(pe, &end_time);

		convert_time_by_offset(&start_time, &start_time, h, m);
		convert_time_by_offset(&end_time, &end_time, h, m);
 
		sprintf(string, "%02d:%02d~%02d:%02d ", start_time.hour, start_time.min,  \
			end_time.hour, end_time.min);
		ComAscStr2Uni(string, (UINT16*)display_strs[23]);
		ComUniStrCopyChar((UINT8*) &display_strs[24][0], s1);

		//draw prog process
		get_local_time(&local_time);
		get_time_offset(&start_time, &end_time, &day, &h, &m, &sec);
		timeLen = day * 24 * 60+h * 60+m;
		get_time_offset(&start_time, &local_time, &day, &h, &m, &sec);
		timePassed = day * 24 * 60+h * 60+m;
		if ((timeLen <= 0) || (timePassed <= 0))
			progProcessLen = 0;
		else
			progProcessLen = timePassed * PROG_PROCESS_W / timeLen;
		if (progProcessLen > PROG_PROCESS_W)
			progProcessLen = PROG_PROCESS_W;
		///prog_process.head.frame.uWidth = progProcessLen;
	}
	else
	{
		MEMSET(string, 0, sizeof(string));
        src8 = OSD_GetUnicodeString(RS_EPG_NO_INFORMATION);
		ComUniStrCopyChar((UINT8*) &display_strs[23][0], src8);
		sprintf(string, " ");
		ComAscStr2Uni(string, (UINT16*)display_strs[24]);
	}
	
	/* Set epg_time_next, epg_next content */
	if (s2)
	{
		MEMSET(string, 0, sizeof(string));
		get_STC_offset(&h, &m, &sec);
		get_event_start_time(fe, &start_time);
		get_event_end_time(fe, &end_time);


		convert_time_by_offset(&start_time, &start_time, h, m);
		convert_time_by_offset(&end_time, &end_time, h, m);

		sprintf(string, "%02d:%02d~%02d:%02d ", start_time.hour, start_time.min,  \
			end_time.hour, end_time.min);

		ComAscStr2Uni(string, display_strs[25]);
		ComUniStrCopyChar((UINT8*) &display_strs[26][0], s2);
	}
	else
	{
		MEMSET(string, 0, sizeof(string));
		sprintf(string, " ");
		ComAscStr2Uni(string, (UINT16*)display_strs[25]);
		ComAscStr2Uni(string, (UINT16*)display_strs[26]);
	}
	return 0;
}