Ejemplo n.º 1
0
static int cmd_comtest(unsigned int argc, unsigned char *argv[])
{
    unsigned int data_len;
#ifdef UPGRADE_ONCE
	if(receive_comtest_falg == FALSE)
		return -1;
#endif

#ifdef PANEL_DISPLAY
#if (SYS_SDRAM_SIZE != 2)
    pan_display(panel_dev,  "conn", 4);
#else
    pan_display(panel_dev,  "UP9", 4);
#endif
#endif

    if (argc != 2)
    {
#ifdef PANEL_DISPLAY
        pan_display(panel_dev,  "r101", 4);
#endif
        SH_PRINTF("Usage: comtest <data_num>\n");
        SH_PRINTF("       Then begin loopback <data_num> charactor to host.\n");
        return -1;
    }

    data_len = ATOI(argv[1]);

    while (data_len--)
        LIB_ASH_OC(LIB_ASH_IC());

    return 0;
}
Ejemplo n.º 2
0
UINT32 cmd_process_monitor(unsigned int argc, unsigned char *argv[])
{
	UINT32 data[6 * 2];
	UINT32 i, j = 0x00000003;
	UINT32 ptm = osal_get_tick();

	MEMSET(data, 0, sizeof(data));
	pan_display(g_pan_dev, "Pdon", 4); // done, all ok!

	for(i = 0; i<6; i++)
	{
		UINT32 pm_finish = 0;
		UINT32 pm2_finish = 0;
		*((volatile UINT32 *)0xb8000300) = (j|i<<16);
		while(1)
		{
			pm_finish = *((volatile UINT32 *)0xb8000304);
			pm2_finish = *((volatile UINT32 *)0xb800030c);
			if(1==(pm_finish&0x1)&&1==(pm2_finish&0x1))
				break;
//			if((osal_get_tick()-ptm) > 2000)
				break;
			osal_task_sleep(1);
		}
		data[2  * i] = pm_finish>>16;
		data[2  * i + 1] = pm2_finish>>16;
		//libc_printf("PM_COUNT:  \t=\t 0x%04x,  \tPM_SEL =  \t%d\n", pm_finish>>16, i);
		//libc_printf("PM_COUNT2: \t=\t 0x%04x,  \tPM_SEL2 =  \t%d\n", pm2_finish>>16, i);
		*((volatile UINT32 *)0xb8000300) = 0;
	}
	
	SendDataPacket(0, (unsigned char *)data, sizeof(data));	
	return 0;
}
Ejemplo n.º 3
0
static void BurnProgress(unsigned int nPercent)
{
	callback_fun(1,nPercent, NULL);
	if(nPercent<100)
	{
		sprintf(msg,"b%d  ",nPercent);
		pan_display(LV_pPanDev,  msg, 4);
	}
}
Ejemplo n.º 4
0
void pan_display_error(UINT32 nErrorCode)
{
	if(LV_pPanDev != NULL)
	{
		sprintf(msg,"e%3d", nErrorCode);
		pan_display(LV_pPanDev,  msg, 4);
	}
	
}
Ejemplo n.º 5
0
static void led_show(unsigned char *patn)
{
    unsigned int i;
    unsigned char led_dispay_str[4];

    for (i = 0; i < 4; i++)
        led_dispay_str[i] = patn[(i + led_display_type) % 2];
    led_display_type++;
    pan_display(panel_dev, led_dispay_str, 4);
}
Ejemplo n.º 6
0
static void led_show(unsigned char *patn)
{
    unsigned int i;
    unsigned char led_dispay_str[5];

    for (i = 0; i < 4; i++)
    {
		if(i>0)
			led_dispay_str[i+1] = patn[(i + led_display_type) % 2];
		else
        	led_dispay_str[i] = patn[(i + led_display_type) % 2];
    }
	led_dispay_str[1] = dot_str[0];
    led_display_type++;
    pan_display(panel_dev, led_dispay_str, 5);
}
Ejemplo n.º 7
0
static void UpgradeProgress(unsigned int nPercent)
{

	trans_size += nPercent;
	INT32 progress = trans_size*100/slave_reorg_size;
	if(progress > prog)
	{
		prog = progress;
		callback_fun(1,prog,NULL);
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
		if(prog<100)
		{
			sprintf(msg,"u%d  ",prog);
			pan_display(LV_pPanDev,  msg, 4);
		}
#endif
	}
				
//	callback_fun(1,nPercent, NULL);	
}
Ejemplo n.º 8
0
static INT32 command_move (INT32 index, UINT32 offset, void (*callback)(INT32 type, INT32 process, UINT8 *str))
{
	INT32 result = (INT32)cmd_move(pslave_list[index].id, offset);
	if(result == SUCCESS)
	{
		INT32 progress = trans_size*100/slave_reorg_size;
		if(progress > prog)
		{
			prog = progress;
			callback(1,prog,NULL);
			if(prog<100)
			{
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
				sprintf(msg,"u%d  ",prog);
				pan_display(LV_pPanDev,  msg, 4);
#endif
			}
		}
	}
	return result;
}
Ejemplo n.º 9
0
/* Update the display. */
void osd_update_video_and_audio(struct osd_bitmap *bitmap)
{
	static const int waittable[FRAMESKIP_LEVELS][FRAMESKIP_LEVELS] =
	{
		{ 1,1,1,1,1,1,1,1,1,1,1,1 },
		{ 2,1,1,1,1,1,1,1,1,1,1,0 },
		{ 2,1,1,1,1,0,2,1,1,1,1,0 },
		{ 2,1,1,0,2,1,1,0,2,1,1,0 },
		{ 2,1,0,2,1,0,2,1,0,2,1,0 },
		{ 2,0,2,1,0,2,0,2,1,0,2,0 },
		{ 2,0,2,0,2,0,2,0,2,0,2,0 },
		{ 2,0,2,0,0,3,0,2,0,0,3,0 },
		{ 3,0,0,3,0,0,3,0,0,3,0,0 },
		{ 4,0,0,0,4,0,0,0,4,0,0,0 },
		{ 6,0,0,0,0,0,6,0,0,0,0,0 },
		{12,0,0,0,0,0,0,0,0,0,0,0 }
	};
	int i;
	static int showfps,showfpstemp;
	TICKER curr;
	static TICKER prev_measure=0,this_frame_base,prev;
	static int speed = 100;
	static int vups,vfcount;
	int have_to_clear_bitmap = 0;

	if (prev_measure==0)
	{
		/* first time through, initialize timer */
		prev_measure = ticker() - FRAMESKIP_LEVELS * TICKS_PER_SEC/video_fps;
	}

	if (frameskip_counter == 0)
		this_frame_base = prev_measure + FRAMESKIP_LEVELS * TICKS_PER_SEC/video_fps;

	/* update audio */
	msdos_update_audio();

	if (osd_skip_this_frame() == 0)
	{
		if (showfpstemp)
		{
			showfpstemp--;
			if (showfps == 0 && showfpstemp == 0)
			{
				have_to_clear_bitmap = 1;
			}
		}

		if (input_ui_pressed(IPT_UI_SHOW_FPS))
		{
			if (showfpstemp)
			{
				showfpstemp = 0;
				have_to_clear_bitmap = 1;
			}
			else
			{
				showfps ^= 1;
				if (showfps == 0)
				{
					have_to_clear_bitmap = 1;
				}
			}
		}

		/* now wait until it's time to update the screen */
		if (throttle)
		{
			profiler_mark(PROFILER_IDLE);
			if (video_sync)
			{
				static TICKER last;
				do
				{
					vsync();
					curr = ticker();
				} while (TICKS_PER_SEC / (curr - last) > video_fps * 11 /10);
				last = curr;
			}
			else
			{
				TICKER target;
				/* wait for video sync but use normal throttling */
				if (wait_vsync)
					vsync();
				curr = ticker();
				target = this_frame_base + frameskip_counter * TICKS_PER_SEC/video_fps;
				if ((curr < target) && (target-curr<TICKS_PER_SEC))
				{
					do
					{
						#ifdef WIZ
						    spend_cycles(1024); // WIZ
						#endif
						curr = ticker();
					} while ((curr < target) && (target-curr<TICKS_PER_SEC));
				}
			}
			profiler_mark(PROFILER_END);
		}
		else curr = ticker();

		if (frameskip_counter == 0)
		{
			int divdr;
			divdr = video_fps * (curr - prev_measure) / (100 * FRAMESKIP_LEVELS);
			if (divdr==0)
			    divdr=1;
			speed = (TICKS_PER_SEC + divdr/2) / divdr;
			prev_measure = curr;
		}

		prev = curr;

		vfcount += waittable[frameskip][frameskip_counter];
		if (vfcount >= video_fps)
		{
			extern int vector_updates; /* avgdvg_go_w()'s per Mame frame, should be 1 */
			vfcount = 0;
			vups = vector_updates;
			vector_updates = 0;
		}

		if (showfps || showfpstemp)
		{
			int fps;
			char buf[30];
			int divdr;
			divdr = 100 * FRAMESKIP_LEVELS;
			fps = (video_fps * (FRAMESKIP_LEVELS - frameskip) * speed + (divdr / 2)) / divdr;
			sprintf(buf,"%s%2d%4d%%%4d/%d fps",autoframeskip?"auto":"fskp",frameskip,speed,fps,(int)(video_fps+0.5));
			ui_text(bitmap,buf,Machine->uiwidth-strlen(buf)*Machine->uifontwidth,0);
			if (vector_game)
			{
				sprintf(buf," %d vector updates",vups);
				ui_text(bitmap,buf,Machine->uiwidth-strlen(buf)*Machine->uifontwidth,Machine->uifontheight);
			}
		}

		if (bitmap->depth == 8)
		{
			if (dirty_bright)
			{
				dirty_bright = 0;
				for (i = 0;i < 256;i++)
				{
					float rate = brightness * brightness_paused_adjust * pow(i / 255.0, 1 / osd_gamma_correction) / 100;
					bright_lookup[i] = 255 * rate + 0.5;
				}
			}
			if (dirtypalette)
			{
				dirtypalette = 0;
				for (i = 0;i < screen_colors;i++)
				{
					if (dirtycolor[i])
					{
						unsigned char r,g,b;
						
						dirtycolor[i] = 0;

						r = current_palette[3*i+0];
						g = current_palette[3*i+1];
						b = current_palette[3*i+2];
						if (i != Machine->uifont->colortable[1])	/* don't adjust the user interface text */
						{
							r = bright_lookup[r];
							g = bright_lookup[g];
							b = bright_lookup[b];
						}
						wiz_video_color8(i,r,g,b);
					}
				}
				wiz_video_setpalette();
			}
		}
		else
		{
			if (dirty_bright)
			{
				dirty_bright = 0;
				for (i = 0;i < 256;i++)
				{
					float rate = brightness * brightness_paused_adjust * pow(i / 255.0, 1 / osd_gamma_correction) / 100;
					bright_lookup[i] = 255 * rate + 0.5;
				}
			}
			if (dirtypalette)
			{
				if (use_dirty) init_dirty(1);	/* have to redraw the whole screen */

				dirtypalette = 0;
				for (i = 0;i < screen_colors;i++)
				{
					if (dirtycolor[i])
					{
						int r,g,b;

						dirtycolor[i] = 0;

						r = current_palette[3*i+0];
						g = current_palette[3*i+1];
						b = current_palette[3*i+2];
						if (i != Machine->uifont->colortable[1])	/* don't adjust the user interface text */
						{
							r = bright_lookup[r];
							g = bright_lookup[g];
							b = bright_lookup[b];
						}
						palette_16bit_lookup[i] = makecol(r,g,b);
					}
				}
			}
		}

		/* copy the bitmap to screen memory */
		profiler_mark(PROFILER_BLIT);
		update_screen(bitmap);
		profiler_mark(PROFILER_END);

		if (have_to_clear_bitmap)
			osd_clearbitmap(bitmap);

		if (use_dirty)
		{
			if (!vector_game)
				swap_dirty();
			init_dirty(0);
		}

		if (have_to_clear_bitmap)
			osd_clearbitmap(bitmap);

		if (throttle && autoframeskip && frameskip_counter == 0)
		{
			static int frameskipadjust;
			int adjspeed;

			/* adjust speed to video refresh rate if vsync is on */
			adjspeed = speed * video_fps / vsync_frame_rate;

			if (adjspeed >= 92)
			{
				frameskipadjust++;
				if (frameskipadjust >= 3)
				{
					frameskipadjust = 0;
					if (frameskip > 0) frameskip--;
				}
			}
			else
			{
				if (adjspeed < 80)
					frameskipadjust -= (90 - adjspeed) / 5;
				else
				{
					/* don't push frameskip too far if we are close to 100% speed */
					if (frameskip < 8)
						frameskipadjust--;
				}

				while (frameskipadjust <= -2)
				{
					frameskipadjust += 2;
#ifdef WIZ
					if (frameskip < 7) frameskip++;
#else
					if (frameskip < FRAMESKIP_LEVELS-1) frameskip++;
#endif
				}
			}
		}
	}

	/* Check for PGUP, PGDN and pan screen */
	pan_display();

	if (input_ui_pressed(IPT_UI_FRAMESKIP_INC))
	{
		if (autoframeskip)
		{
			autoframeskip = 0;
			frameskip = 0;
		}
		else
		{
			if (frameskip == FRAMESKIP_LEVELS-1)
			{
				frameskip = 0;
				autoframeskip = 1;
			}
			else
				frameskip++;
		}

		if (showfps == 0)
			showfpstemp = 2*video_fps;
	}

	if (input_ui_pressed(IPT_UI_FRAMESKIP_DEC))
	{
		if (autoframeskip)
		{
			autoframeskip = 0;
			frameskip = FRAMESKIP_LEVELS-1;
		}
		else
		{
			if (frameskip == 0)
				autoframeskip = 1;
			else
				frameskip--;
		}

		if (showfps == 0)
			showfpstemp = 2*video_fps;
	}

	if (input_ui_pressed(IPT_UI_THROTTLE))
	{
		throttle ^= 1;
	}

	frameskip_counter = (frameskip_counter + 1) % FRAMESKIP_LEVELS;
}
Ejemplo n.º 10
0
/* Updata whole flash with LED support only */
INT32 sys_upgrade4(char* ledstr,void (*callback)(INT32 type, INT32 process, UINT8 *str), UINT32 (*GetExitKey)(void))
{
	UINT32 result = SUCCESS;
	INT32 i;
	INT32 retry_count=0;
	char strTmp[30];
	char strTmp1[30];
	char strTmp2[30];
	char strTmp3[30];
	char strTmp4[30];
	char strTmp5[30];
	char strTmp6[30];
	char strTmp7[30];
	char strTmp8[30];
	char strTmp9[30];
	
	get_exit_key = GetExitKey;
	callback_fun = callback;

	
	LV_pPanDev = (struct pan_device *) dev_get_by_type(NULL, HLD_DEV_TYPE_PAN);
	if(NULL == LV_pPanDev)
	{
		PRINTF("dev_get_by_name failed\n");
		return !SUCCESS;
	}
	if(pan_open(LV_pPanDev)!=SUCCESS)
	{
		PRINTF("pan_open failed\n");
		return !SUCCESS;
	}

	//pan_display(LV_pPanDev,  "up9 ", 4);
#ifdef THREE_DIGITS_PANEL
	pan_display(LV_pPanDev,  " up9", 4);
#else
	pan_display(LV_pPanDev,  "up9 ", 4);
#endif

	MG_Setup_CRC_Table();

	/* Check sci port */
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MSG_UPGRADE_CHECK_SERIAL_PORT),strTmp);
	callback(3,0,strTmp);

	result = cmd_comtest(&g_protocol_version, NULL, GetExitKey);
	if(result != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CONNECT_FAILED),strTmp1);
		callback(2,0,strTmp1);
		return !SUCCESS;
	}

    	p2p_delay();
    ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_COLLECTING_VERSION_INFO),strTmp2);
	callback(2,0,strTmp2);
	if((result = cmd_version(&g_protocol_version)) != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp3);
		callback(2, 0, strTmp3);
		return !SUCCESS;
	}
	
	p2p_delay();


	if((result = cmd_address(0x0)) != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp4);
		callback(2, 0, strTmp4);
		return !SUCCESS;
	}

	trans_size = 0;
	prog = 0;
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_TRANSFERING_DATA),strTmp5);
	callback(3,0,strTmp5);
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "u0  ", 4);
#endif
	result = command_transferraw(callback);
	if(result != SUCCESS)
   	{
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp6);
		callback(2, 0, strTmp6);
		return !SUCCESS;
   	}
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "u100 ", 4);
#endif

    	p2p_delay();
	/* Send command to burn flash */
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_BURNING_FLASH),strTmp7);
	callback(3,0,strTmp7);
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "b0  ", 4);
#endif
	if((result = command_burn_new(callback, FALSE)) != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp8);
		callback(2,0,strTmp8);
		return !SUCCESS;
	}

#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "100 ", 4);
#endif
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_SUCCESSFUL),strTmp9);
	callback(2, 0,strTmp9);

	return SUCCESS;
}
Ejemplo n.º 11
0
INT32 sys_upgrade_process(void (*callback)(INT32 type, INT32 process, UINT16 *str), UINT32 (*GetExitKey)(void), int nType)
{
	UINT32 result = SUCCESS;
	INT32 i;
	INT32 retry_count=0;
	BOOL bReboot = TRUE;
	BOOL bBurn = TRUE;
	char strTmp[30];
	char strTmp1[30];
	char strTmp2[30];
	char strTmp3[30];
	char strTmp4[30];
	char strTmp5[30];
	char strTmp6[30];
	char strTmp7[30];
	char strTmp8[30];
	char strTmp9[30];
	char strTmp10[30];
	char strTmp11[30];
	char strTmp12[30];
	char strTmp13[30];
	char strTmp14[30];

	if(nType == 2 || nType == 3)
		bReboot = FALSE;
	
	if(nType == 3)
		bBurn = FALSE;
	
	get_exit_key = GetExitKey;
	callback_fun = callback;
	
	LV_pPanDev = (struct pan_device *) dev_get_by_type(NULL, HLD_DEV_TYPE_PAN);
	if(NULL == LV_pPanDev)
	{
		PRINTF("dev_get_by_name failed\n");
		return !SUCCESS;
	}
	if(pan_open(LV_pPanDev)!=SUCCESS)
	{
		PRINTF("pan_open failed\n");
		return !SUCCESS;
	}

	//pan_display(LV_pPanDev,  "up9 ", 4);
#ifdef THREE_DIGITS_PANEL
	pan_display(LV_pPanDev,  " up9", 4);
#else
	pan_display(LV_pPanDev,  "up9 ", 4);
#endif

#ifdef ENABLE_EROM
    init_buffer();
//    uart_reset();
    osal_task_sleep(100);
    uart_high_speed_config(UART_SPEED_NORMAL);
    do
    {
        if(!sync_slave((UPGRADE_MULTI==upgrade_mode)?M2S_MODE:P2P_MODE, 1000))
            return !SUCCESS; ;
        //uart_high_speed_config(UART_HIGH_SPEED_2M);
        if(!init_slave()) // after init slave, uart 6M high bitrate is applied
            return !SUCCESS;;
    }while(0);
#endif

	MG_Setup_CRC_Table();

	/* Check sci port */
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MSG_UPGRADE_CHECK_SERIAL_PORT),strTmp);
	callback(3,0,strTmp);

	result = cmd_comtest(&g_protocol_version, NULL, GetExitKey);
	if(result != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CONNECT_FAILED),strTmp1);
		callback(2,0,strTmp1);
		return !SUCCESS;
	}

    	p2p_delay();
    ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_COLLECTING_VERSION_INFO),strTmp2);
	callback(2,0,strTmp2);
	if((result = cmd_version(&g_protocol_version)) != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp3);
		callback(2, 0, strTmp3);
		return !SUCCESS;
	}
	
	
	p2p_delay();
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_COMPARE_SLAVE_REORG),strTmp4);
	callback(2,0,strTmp4);
	if((result =SlaveReorg(callback)) != SUCCESS)
	{
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp5);
		callback(2,0,strTmp5);
		return !SUCCESS;
	}

	p2p_delay();

	UINT32 addr = 0x0;
	if(pslave_reorg_list[0].type == 2)  //transfer bootloader
	{
		addr = 0x0;
	}
	else
	{
#if (SYS_PROJECT_FE	== PROJECT_FE_DVBT && SYS_SDRAM_SIZE == 2)
		addr = 0x7800;
#else
#if (SYS_CHIP_MODULE == ALI_M3327C && SYS_SDRAM_SIZE == 2)
		//addr = 0xc000;
		//add logo data, so the address is changed
        addr = 0x8000;
#else
		addr = pslave_list[0].offset;
#endif
#endif
	}
	if((result = cmd_address(addr)) != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp6);
		callback(2, 0, strTmp6);
		return !SUCCESS;
	}

	trans_size = 0;
	prog = 0;
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_TRANSFERING_DATA),strTmp7);
	callback(3,0,strTmp7);
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "u0  ", 4);
#endif
	for(i=0; i<slave_reorg_number;i++)
	{
		p2p_delay();

		if(pslave_reorg_list[i].type==1) //move
		{
			if(i==0)  continue;
			result = command_move(pslave_reorg_list[i].index, pslave_reorg_list[i].offset, callback);
			if(result != SUCCESS)
			{
				pan_display_error(result);
				ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MOVE_FAILED_TRY_AGAIN),strTmp8);
				callback(2,0,strTmp8);
				return !SUCCESS;
			}
			
		}
		else //transfer
		{
			result = command_transfer(pslave_reorg_list[i].index,callback);
			if(result != SUCCESS)
			{
				pan_display_error(result);
				ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_TRANSFER_FAILED_TRY_AGAIN),strTmp9);
				callback(2,0,strTmp9);
				return !SUCCESS;
			}
		}
	}
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "100 ", 4);
#endif

    	p2p_delay();
	/* Send command to burn flash */
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MSG_UPGRADE_BURN_FLASH),strTmp10);
	callback(3,0,strTmp10);
	pan_display(LV_pPanDev,  "burn ", 4);
		
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "b0  ", 4);
#endif

	if((result = command_burn_new(callback, bBurn)) != SUCCESS)
	{
		pan_display_error(result);
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp11);
		callback(2,0,strTmp11);
		return !SUCCESS;
	}
		
#if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2)
	pan_display(LV_pPanDev,  "100 ", 4);
#endif
	pan_display(LV_pPanDev,  "end ", 4);
	/*reboot slaver*/
	if(bReboot)
	{
		ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_REBOOTING_SLAVER),strTmp12);
		callback(2,0,strTmp12);
	    if(command_reboot(callback) != SUCCESS)
	    {
	    	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp13);
	        callback(2,0,strTmp13);
	        return !SUCCESS;
	    }
	}
	ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_SUCCESSFUL),strTmp14);
	callback(2, 0, strTmp14);

	return SUCCESS;
}
Ejemplo n.º 12
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	
}
Ejemplo n.º 13
0
UINT32 cmd_stbid(unsigned int argc, unsigned char *argv[])
{
	UINT8 i = 0, j = 0, ch = 0xff;
	UINT8 *_stbid_flag = "SRI";
	INT32 _stbid_flag_len = 3;
	UINT8 _serial_data[1024]; // max receive 1KB data
	UINT32 timeout = 1000, stbid_offset = STB_HWINFO_SERIAL_OFF, _stbid_crc = 0, _stbid_len = 0, _serial_len = 0, _crc = 0, _crc_pos = 0;
	UINT8 *buffer = NULL;
	UINT32 nReturn = SUCCESS;
	UINT32 nPacketNum = 0;
	PACKET packet;
	UINT32 tick = osal_get_tick();
	UINT8 retry_num = 5, _tr_num = 5;
	ID _task_id = g_com_ash_id;
	
	osal_task_dispatch_off();	
	
	SendStatusPacket(COMMAND_STATUS_OK,  0);
	pan_display(g_pan_dev, "Stb-", 4);
	
RETRY:	
	_tr_num = 5;
	
	//transfer data
	MEMSET(&packet, 0, sizeof(PACKET));
	
	nReturn = packet_receive(&packet, 5 * 1000);
	if(SUCCESS != nReturn)
	{
		SERIAL_DEBUG("receive packet fail!\n");	
		retry_num--;
		goto RETURN;
	}
	
	if(packet.packet_type == PACKET_DATA)
	{	
		_serial_len = packet.packet_length-4;
		MEMCPY(_serial_data, packet.data_buffer+4, packet.packet_length-4);
	}
	else
	{
		SERIAL_DEBUG("receive %d packet, ignore!\n", packet.packet_type);
		retry_num--;
		goto RETURN;
	}
	
	SERIAL_DEBUG("stbid get data total len %d finish, data: \n", _serial_len);
	for(i=0; i<_serial_len; i++)
	{
		SERIAL_DEBUG("%c", _serial_data[i]);
	}
	SERIAL_DEBUG("\n");
	
	pan_display(g_pan_dev, "GET", 4);
	if((_serial_data[0] != _stbid_flag[0]) || (_serial_data[1] != _stbid_flag[1]) || (_serial_data[2] != _stbid_flag[2])) // received flag tag
	{
		SERIAL_DEBUG("Error: SRI flag missing!\n");	
		retry_num--;
		goto RETURN;
	}
	
	pan_display(g_pan_dev, "FLAG", 4);
	_stbid_len = _serial_len-4-8;
	if(_stbid_len > STB_HWINFO_MAC_OFF)
	{
		SERIAL_DEBUG("Error: stbid len %d != [%d], please resend cmd!\n", _stbid_len, STB_HWINFO_MAC_OFF);
		retry_num--;
		goto RETURN;
	}
	
	pan_display(g_pan_dev, "LENG", 4);
	
	// do crc check
	_crc_pos = _stbid_flag_len+1+_stbid_len;
	_stbid_crc = 0;
	for(i=0; i<8; i++)
	{
		_stbid_crc |= (((_serial_data[_crc_pos+i]>'9') ? (_serial_data[_crc_pos+i]-'A'+10) : (_serial_data[_crc_pos+i]-'0'))<<((7-i)*4));
	}
	
	_crc = MG_Table_Driven_CRC(0xFFFFFFFF, _serial_data, _crc_pos);
	if(_stbid_crc != _crc)
	{
		// fail, need re-trans
		SERIAL_DEBUG("stbid crc fail, calcu = 0x%x!\n", _crc);
		retry_num--;
		goto RETURN;
	}
	
	pan_display(g_pan_dev, "CRC", 4);
	// burn code, enable drive auto-erase
	for(i=0; i<(STB_HWINFO_OUI_OFF-STB_HWINFO_MAC_OFF); i++) // init mac
	{
		ch = _serial_data[STB_HWINFO_MAC_OFF+4-12+i*2];
		_serial_data[i+STB_HWINFO_MAC_OFF+4] = (((ch>'9') ? ((ch>='a') ? (ch-'a'+10) : (ch-'A'+10)) : (ch-'0'))<<4);
		ch = _serial_data[STB_HWINFO_MAC_OFF+4-12+i*2+1];
		_serial_data[i+STB_HWINFO_MAC_OFF+4] |= ((ch>'9') ? ((ch>='a') ? (ch-'a'+10) : (ch-'A'+10)) : (ch-'0'));
	}
	
	buffer = MALLOC(64*1024);
	if(buffer == NULL)
	{
		SDBBP();
	}
	
	sto_io_control(g_sto_dev, STO_DRIVER_SECTOR_BUFFER, (UINT32)buffer);
	sto_io_control(g_sto_dev, STO_DRIVER_SET_FLAG, STO_FLAG_AUTO_ERASE|STO_FLAG_SAVE_REST);
	
	SERIAL_DEBUG("Now burn stbid: ");	
	for(i=0; i<STB_HWINFO_OUI_OFF; i++)
	{
		SERIAL_DEBUG("%c", _serial_data[i+_stbid_flag_len+1]);
	}
	SERIAL_DEBUG("\n");
	
	sto_put_data(g_sto_dev, STB_HWINFO_BASE_ADDR, &_serial_data[_stbid_flag_len+1], STB_HWINFO_OUI_OFF);	
	if(buffer)
	{
		FREE(buffer);
		buffer = NULL;
		sto_io_control(g_sto_dev, STO_DRIVER_SECTOR_BUFFER, 0);
		sto_io_control(g_sto_dev, STO_DRIVER_SET_FLAG, 0);
	}
	
	if(g_stb_hwinfo != NULL)
	{
		FREE(g_stb_hwinfo);
		g_stb_hwinfo = NULL;
	}
	
	pan_display(g_pan_dev, "-tr-", 4);
	SERIAL_DEBUG("stbid finish, task %d deleted!\n", g_com_ash_id);
	SERIAL_DEBUG("cmd_stbid takes %dms\n", osal_get_tick()-tick);
	retry_num = 0;

RESEND:	
	SendStatusPacket(COMMAND_STATUS_DONE, 0);
	MEMSET(&packet, 0, sizeof(PACKET));
	osal_task_sleep(100);
	
	nReturn = packet_receive(&packet, 5 * 1000);
	if((SUCCESS != nReturn) || (packet.packet_type != PACKET_STATUS))
	{
		if(_tr_num-- > 0)
		{
			SERIAL_DEBUG("stbid finish, but signal send fail, now re-send!\n");
			goto RESEND;
		}
		else
		{
			pan_display(g_pan_dev, "dStb", 4); // done, but notice fail!
		}
	}
	else
	{
		pan_display(g_pan_dev, "-Stb", 4); // done, all ok!
	}
	
RETURN:
	if(retry_num >0)
	{
		SendStatusPacket(COMMAND_STATUS_ERROR, 0);
		goto RETRY;
	}
	else
	{
		SERIAL_DEBUG("error, please redo!\n");
		api_set_com_check_flag(COM_MONITOR_CHECK_STBID);
	}
	
	g_com_ash_id = INVALID_ID;
	osal_task_dispatch_on();
	osal_task_delete(_task_id);
}