Exemplo n.º 1
0
DWORD TrayIconThread(LPVOID pvarg)
{
    LPCTSTR     szClassName = _T("ZTrayIcon");

    WNDCLASS    wc;

    /*while(!IsAPIReady(SH_SHELL))
        {}*/
    WaitForAPIReady(SH_SHELL, INFINITE);


    if(hTrayIcon == NULL)
    {
        ZeroMemory(&wc, sizeof(wc));
        wc.lpfnWndProc = IconProc;
        wc.hInstance   = GetModuleHandle(NULL);
        wc.lpszClassName = szClassName;
        wc.hCursor = NULL;
        wc.hbrBackground = NULL;
        RegisterClass(&wc);

        hTrayIcon = CreateWindow(szClassName, _T(""), WS_POPUP | WS_CLIPCHILDREN, 0, 0, 0, 0, NULL, NULL, wc.hInstance, NULL);


        MSG  msg;

        while(GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }

        hTrayIcon = NULL;
    }


    RETAILMSG(1, (TEXT("\n\rExitIconProc -> TrayIconThread\n\r")));

    return 0;
}
Exemplo n.º 2
0
RESULT
LayerManager::Draw()
{
    RESULT rval = S_OK;
    ResourceListIterator ppLayer;

    //
    // Render the Layer and any children.
    //
//    CHR(Renderer.EnableDepthTest ( true ));
    CHR(Renderer.EnableDepthTest ( false ));
    CHR(Renderer.EnableLighting  ( false ));
//    CHR(Renderer.EnableAlphaBlend( true  ));
    CHR(Renderer.EnableAlphaTest ( false ));   // Alpha Test on iPhone (3G) is not any faster than Alpha Blend.
    CHR(Renderer.EnableTexturing ( true  ));
    
    
    for (ppLayer = m_resourceList.begin(); ppLayer != m_resourceList.end(); ++ppLayer)
    {
        Layer* pLayer = *ppLayer;
        DEBUGCHK(pLayer);
        
        // Only draw root layers in this method.
        // They in turn draw their children.
        // We can have multiple roots (e.g. the game world and the UI).
        if (pLayer->IsRootLayer())
        {
            CHR(Draw( pLayer, GameCamera.GetViewMatrix() ));
        }
    }
    
Exit:
    if (FAILED(rval))
    {
        RETAILMSG(ZONE_ERROR, "ERROR: LayerManager::Draw(): rval = 0x%x", rval);
        DEBUGCHK(0);
    }

    return rval;
}
/**
*    @fn    PwrCon_get_reset_statys(void)
*    @note  This funciton read the reset status which means what trigger reset the system in the last time
*/
RESET_STATUS PwrCon_get_reset_status(void)
{
    RESET_STATUS RstStatus = RST_UNKNOWN;
    
    assert(g_pSysConReg->NORMAL_CFG);    
    
    RstStatus = g_pSysConReg->RST_STAT;
    
    switch(RstStatus)
    {
    case RST_HW_RESET:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:INF] %s() : H/W Reset [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    case RST_WARM_RESET:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:INF] %s() : Warm Reset [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    case RST_WDT_RESET:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:INF] %s() : Watch Dog Timer Reset [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    case RST_SLEEP_WAKEUP:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:INF] %s() : Sleep/Wakeup Reset [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    case RST_ESLEEP_WAKEUP:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:INF] %s() : eSleep/Wakeup Reset [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    case RST_SW_RESET:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:INF] %s() : S/W Reset [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    default:
        RETAILMSG(PWC_ZONE_TEMP, (_T("[PWRCON:ERR] %s() : Unknown RST_STAT [0x%08x]\n"), _T(__FUNCTION__), g_pSysConReg->RST_STAT));
        break;
    }

    RETAILMSG(PWC_ZONE_ENTER, (_T("[PWRCON] %s() = %d\n"), _T(__FUNCTION__), RstStatus));

    return RstStatus;
}
Exemplo n.º 4
0
/**
*    @fn    DWORD FIMGSE2D::CalculateXYIncrFormat(DWORD uDividend, DWORD uDivisor)
*    @brief    This function returns x_incr or y_incr vaule in register format
*    @input    this function accept real pixel coordinate, ex) (0,0)~(9,9) means that 10pixel by pixel image
*    @return    Result value
*/
DWORD FIMGSE2D::CalculateXYIncrFormat(DWORD uDividend, DWORD uDivisor)
{
    int i;
    DWORD uQuotient;
    DWORD uUnderPoint=0;

    if(uDivisor == 0)
    {
        uDivisor = 1;    //< this will prevent data abort. but result is incorrect.
    }

    uQuotient = (DWORD)(uDividend/uDivisor);
    // Quotient should be less than MAX_XCOORD or MAX_YCOORD.
    if(uQuotient > MAX_2DHW_XCOORD) 
    {
        RETAILMSG(DISP_ZONE_WARNING, (TEXT("Increment value to stretch can not exceed %d, Value will be set as 1.0\n"), MAX_2DHW_XCOORD));
        return ((1<<11) | 0 );
    }

    uDividend-=(uQuotient*uDivisor);

    /// Now under point is calculated.
    for (i=0; i<12; i++)
    {
        uDividend <<= 1;
        uUnderPoint <<= 1;

        if (uDividend >= uDivisor)
        {
            uUnderPoint = uUnderPoint | 1;
            uDividend -= uDivisor;
        }
        DEBUGMSG(DISP_ZONE_2D, (TEXT("uDivend:%x(%d), uDivisor:%x(%d), uUnderPoint:%x(%d)\n"), uDividend, uDividend, uDivisor, uDivisor,uUnderPoint, uUnderPoint));
    }

    uUnderPoint = (uUnderPoint + 1) >> 1;

    return ( uUnderPoint|(uQuotient<<11) );
}
Exemplo n.º 5
0
static DWORD WINAPI 
DetectFSCUIReadyThread(
							VOID *pPddContext
							)
{

    HANDLE hUIReady;
	DWORD code;


	hUIReady = OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("SYSTEM/BackCarUIReady"));
	if(NULL == hUIReady)
	{
			RETAILMSG(TRUE, (TEXT("Open SYSTEM/BackCarUIReady Failed\r\n")));
			return -1;
	}
	
	code = WaitForSingleObject(hUIReady, INFINITE);

	CloseHandle(hUIReady);
	return 0;
}
Exemplo n.º 6
0
/**
*    @fn    FIMGSE2D::GetCompensatedOffset(PRECTL prclSrc, PRECTL prclDst, ROT_TYPE m_iRotate)
*    @param    prclSrc    Source Rectangle
*    @param    prclDst    Destination Rectangle
*    @param    m_iRotate    Rotatation Degree. See also ROT_TYPE type
*    @note This funciton performs getting offset for stretchblt algorithm compensation
*    @sa    ROT_TYPE
*
**/
LONG FIMGSE2D::GetCompensatedOffset(DWORD usSrcValue, DWORD usDstValue)
{
    /// Calculate X,Y Offset
    float fIncrement;
    float fStretchRatio;
    float fReferPoint = 0.5;
    LONG i =0;
    
    fIncrement = (float)usSrcValue / (float)usDstValue;
    fStretchRatio = (float)usDstValue / (float)usSrcValue;
    
    do
    {
        if(fReferPoint > 1) break;    
        fReferPoint += fIncrement;
        i++;
    } while(1);

    RETAILMSG(DISP_ZONE_2D,(TEXT("\n fIncr : %5.6f, fSR: %5.6f, i : %d, Offset : %d"), fIncrement, fStretchRatio, i, (LONG)(fStretchRatio - i)));
    
    return (fStretchRatio < 1) ? 0 : (LONG)(fStretchRatio - i);
}
Exemplo n.º 7
0
int Cat9555::GetCAT9555(int channel,unsigned char port,unsigned char *level)
{
	if(channel==0) h= CreateFile(TEXT("CAT1:"), (GENERIC_READ|GENERIC_WRITE), (FILE_SHARE_READ|FILE_SHARE_WRITE), 0, OPEN_EXISTING, 0, 0);
	
	if(channel==1) h= CreateFile(TEXT("CTA1:"), (GENERIC_READ|GENERIC_WRITE), (FILE_SHARE_READ|FILE_SHARE_WRITE), 0, OPEN_EXISTING, 0, 0);

	if(channel==2) h= CreateFile(TEXT("ACT1:"), (GENERIC_READ|GENERIC_WRITE), (FILE_SHARE_READ|FILE_SHARE_WRITE), 0, OPEN_EXISTING, 0, 0);
	
	if(h == INVALID_HANDLE_VALUE)
	{
		RETAILMSG(1, (L"open gpio device failed\r\n"));
		exit(-1);
	}
	if(channel==0) DeviceIoControl(h, IOCTL_CAT9555_READ, &port, sizeof(unsigned char), level, sizeof(unsigned char), NULL, NULL);
	
	if(channel==1) DeviceIoControl(h, IOCTL_CAT95552_READ, &port, sizeof(unsigned char), level, sizeof(unsigned char), NULL, NULL);

	if(channel==2) DeviceIoControl(h, IOCTL_CAT95553_READ, &port, sizeof(unsigned char), level, sizeof(unsigned char), NULL, NULL);
	
	CloseHandle(h);
	return 1;
}
Exemplo n.º 8
0
static BOOL RegOpenCreateStr(LPCTSTR lpSubKey, LPCTSTR lpName, LPTSTR lpData, DWORD dwCnt, BOOL bCreate)
{
	HKEY hKey;
	DWORD dwValue, dwType = REG_MULTI_SZ;
	BOOL bRet = TRUE;

	if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_LOCAL_MACHINE,
		lpSubKey,
		0,
		NULL,
		0,	// REG_OPTION_NON_VOLATILE
		0,
		0,
		&hKey,
		&dwValue))
	{
		return FALSE;
	}

	if (FALSE == bCreate && REG_CREATED_NEW_KEY == dwValue)
	{
		bRet = FALSE;
	}
	else if (REG_OPENED_EXISTING_KEY == dwValue)
	{
		if (ERROR_SUCCESS == RegQueryValueEx(hKey, lpName, 0, &dwType, (BYTE *)lpData, &dwCnt))
			RETAILMSG(0, (_T("%s\r\n"), lpData));
		else
			bRet = FALSE;
	}
	else
	{
		bRet = FALSE;
	}

	RegCloseKey(hKey);

	return bRet;
}
Exemplo n.º 9
0
RESULT
Animation::CallbackOnFinished( ICallback& callback )
{
    RESULT rval = S_OK;
    
    if (callback.IsNull())
    {
        RETAILMSG(ZONE_ERROR, "ERROR: Animation::CallbackOnFinished( \"%s\", 0x%x ): Callback is NULL",
                  m_name.c_str(), (UINT32)&callback);
        
        SAFE_DELETE(m_pCallbackOnFinished);
        
        rval = E_INVALID_ARG;
        goto Exit;
    }
    
    SAFE_DELETE(m_pCallbackOnFinished);
    m_pCallbackOnFinished = callback.Clone();
    
Exit:
    return rval;
}
Exemplo n.º 10
0
RESULT 
GradientEffect::Init()
{
    RETAILMSG(ZONE_SHADER, "GradientEffect::Init()");

    RESULT rval = S_OK;

    if (s_GradientShadersLoaded)
    {
        return S_OK;
    }

    CHR(OpenGLESEffect::Init());

    CHR(ShaderMan.CreateShader( "GradientEffect", s_GradientVertexShaderName, s_GradientFragmentShaderName, &s_hGradientShader ));
    
    // Save uniform handles.
    s_GradientShaderProgram = ShaderMan.GetShaderProgramID( s_hGradientShader );
    VERIFYGL(glUseProgram(s_GradientShaderProgram));

    VERIFYGL(s_uModelViewMatrix     = glGetUniformLocation(s_GradientShaderProgram, "uMatModelView"));
    VERIFYGL(s_uProjectionMatrix    = glGetUniformLocation(s_GradientShaderProgram, "uMatProjection"));
    VERIFYGL(s_uTexture             = glGetUniformLocation(s_GradientShaderProgram, "uTexture"));
    VERIFYGL(s_uStartColor          = glGetUniformLocation(s_GradientShaderProgram, "uStartColor"));
    VERIFYGL(s_uStartPoint          = glGetUniformLocation(s_GradientShaderProgram, "uStartPoint"));
    VERIFYGL(s_uEndColor            = glGetUniformLocation(s_GradientShaderProgram, "uEndColor"));
    VERIFYGL(s_uEndPoint            = glGetUniformLocation(s_GradientShaderProgram, "uEndPoint"));
    VERIFYGL(s_uGlobalColor         = glGetUniformLocation(s_GradientShaderProgram, "uGlobalColor"));
    VERIFYGL(s_uWidth               = glGetUniformLocation(s_GradientShaderProgram, "uWidth"));
    VERIFYGL(s_uHeight              = glGetUniformLocation(s_GradientShaderProgram, "uHeight"));
//    VERIFYGL(s_uTexCoordOffset      = glGetUniformLocation(s_GradientShaderProgram, "uTexCoordOffset"));
    

    s_GradientShadersLoaded = true;

Exit:
    return rval;
}
Exemplo n.º 11
0
/*************************************************************************************
// 	       Function: BspGetBatteryFlag
// 	     Purpose: Give a AC status to upper layer
//       Returns: TRUE--ACOnline  FALSE--ACOff
//***********************************************************************************/
UCHAR 
BspGetBatteryFlag_old (void)
{
 //           return PDD_BATTERY_ON;

    if(BspBatteryDetect())
    {
        if(BspChargerDetect())
            return PDD_BATTERY_CHARGING;
        else if(BspAdapterDetect()||BspUSBChargerDetect())
           {
      		  RETAILMSG(0, (TEXT("++PDD_BATTERY_EOC \r\n")));
	         BspCorrectVoltageGauge();
                return PDD_BATTERY_EOC;
           }		
        else
            return PDD_BATTERY_ON;
    }
    else
    {
        return PDD_NO_BATTERY;
    }
}//endof BspGetBatteryStatus
Exemplo n.º 12
0
BOOL LED_Deinit(DWORD dwContext)
{
	PDRVCONTEXT pDrv = (PDRVCONTEXT)dwContext;
	
	RETAILMSG(RETAIL_ON, (DTAG TEXT("LED_Deinit++ dwContext: %x\r\n"), dwContext));

	// Verify that the context handle is valid
	if(pDrv && (pDrv->dwSize != sizeof(DRVCONTEXT))){
		return 0;
	}

	// terminate thread
	KillFlag = true;
	SetEvent(pDrv->hEvent);

	FreeIntChainHandler(pDrv->hIsrHandle);
	InterruptDisable(pDrv->dwSysIntr);
	KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &pDrv->dwSysIntr, sizeof(DWORD), NULL, 0, NULL);
	CloseHandle(pDrv->hEvent);
	DeleteStaticMapping((LPVOID)isr_info.pGPIORegs, sizeof(GPIOREG));

	return true;
}
Exemplo n.º 13
0
BOOL GetARM2BackCarStatus(UCHAR *pOutBuffer,DWORD outSize,DWORD *pOutSize)
{
	UINT32	g_u4Param1,g_u4Param2,g_u4Param3;
    DWORD dwRet;
	UINT32 u4ModuleID,u4MessageID;
	HWSendMessage(MSG_COMBINE(MODULE_BCAR, MSG_WINCE_APP_READY),0, 0, 0);
			
			
	dwRet = WaitForSingleObject(g_hBackCarIntrEvt, INFINITE);
			
	HWGetMessage(MODULE_BCAR, &u4ModuleID, &g_u4Param1, &g_u4Param2, &g_u4Param3);
			
	u4MessageID = GETMESSAGEID(u4ModuleID);
	if(u4MessageID == MSG_ARM2_RESPONSE)
	   RETAILMSG(TRUE, (TEXT("[FSC][INFO]Rev ARM2 Responese\r\n")));
			
			
	memcpy(pOutBuffer,(UCHAR *)&g_u4Param1,4);
	memcpy(pOutBuffer+4,(UCHAR *)&g_u4Param2,4);
	*pOutSize = 8;
	InterruptDone(g_dwBackCarSysIntr);
	return TRUE;
}
Exemplo n.º 14
0
static DWORD WINAPI mfc_demo_thread(LPVOID pPARAM)
{
    MFCDEC_DEMO_THREAD_PARAM    *p_mfc_demo_param;
    int  idx;

    if (pPARAM == NULL) {
        return 0x0FFFF;
    }

    p_mfc_demo_param = (MFCDEC_DEMO_THREAD_PARAM *) pPARAM;
    idx = p_mfc_demo_param->demofile_idx;

    RETAILMSG(1, (L"\n[MFC_DEMO] Playing \'%s\' file", array_pszFileNames[idx][0]));

#define NUM_PIP_VIDEOS        1
    mfcdec_demo(p_mfc_demo_param->hWnd,
                array_pszFileNames[idx],
                array_codec_modes[idx],
                NUM_PIP_VIDEOS,
                &(p_mfc_demo_param->fForceExit));

    return 0;
}
Exemplo n.º 15
0
BOOL WSM_AddLogData(LPTSTR strBuf)
{
	int nlen = 0;
	int nGlbBufferLen = 0;
	int nspare = 0;


	EnterCriticalSection(&g_csLock);

	// 버퍼 사이즈 할당이 되지 않았다면, 기본사이즈로 할당
	if(g_pBuffer == NULL)
	{
		if( WSM_SetLogBufSize(DEFAULT_LOGBUF_SIZE) == FALSE )
		{
			return FALSE;
		}
	}

	nlen = _tcslen(strBuf) * sizeof(TCHAR);
	nGlbBufferLen =_tcslen(g_pBuffer) * sizeof(TCHAR);

	nspare = g_dwBufSize - nGlbBufferLen;


	RETAILMSG(1, (TEXT("[WSM] g_dwBufSize(%d), nlen(%d), nspare(%d), nGlbBufferLen(%d) \r\n"), g_dwBufSize,  nlen, nspare, nGlbBufferLen ));

	if( nspare < nlen)
	{
		wcscpy(&g_pBuffer[0], &g_pBuffer[nlen - nspare]);
	}
	
	wcscat(g_pBuffer, strBuf);

	LeaveCriticalSection(&g_csLock);

	return TRUE;
}
Exemplo n.º 16
0
//------------------------------------------------------------------------------
//
//  Function:  SetPowerState
//
//  Sets the device power state
//
BOOL SetPowerState(
    KeypadDevice_t         *pDevice, 
    CEDEVICE_POWER_STATE    power)
{
    BOOL rc = FALSE;
    
    DEBUGMSG(ZONE_FUNCTION, (
        L"+SetPowerState(0x%08X, 0x%08x)\r\n", pDevice, power
        ));

    switch (power)
        {
        case D0:
        case D1:
        case D2:
        case D3:
        case D4:
            break;

        default:
            RETAILMSG(ZONE_WARN, (L"WARN: KPD::SetPowerState: "
                L"Invalid power state (%d)\r\n", power
                ));            
            goto cleanUp;
        }

    pDevice->powerState = power;

    rc = TRUE;
    
cleanUp:
    DEBUGMSG(ZONE_FUNCTION, (
        L"-SetPowerState(0x%08X, 0x%08x)\r\n", pDevice, power
        ));
        
    return rc;
}
Exemplo n.º 17
0
static BOOL dispBitmap(HDC hDC, LPCTSTR lpszFileName)
{
	HANDLE hFile = CreateFile(lpszFileName,
		GENERIC_READ, FILE_SHARE_READ,
		NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (INVALID_HANDLE_VALUE == hFile)
		return FALSE;

	DISPBITMAP dispBmp;
	dispBmp.nCount = (int)GetFileSize(hFile, NULL);
	dispBmp.x = dispBmp.y = 0;
	dispBmp.pBuffer = new BYTE [dispBmp.nCount];
	if (NULL == dispBmp.pBuffer)
	{
		CloseHandle(hFile);
		return FALSE;
	}

	DWORD dwNumberOfBytesRead;
	ReadFile(hFile, dispBmp.pBuffer, dispBmp.nCount, &dwNumberOfBytesRead, NULL);
	if (dispBmp.nCount != dwNumberOfBytesRead)
	{
		CloseHandle(hFile);
		delete [] dispBmp.pBuffer;
		return FALSE;
	}

	dispBmp.pUpdate = NULL;
	dispBmp.bIsWait = TRUE;
	int nRet = ExtEscape(hDC, DRVESC_DISP_BITMAP, sizeof(dispBmp), (LPCSTR)&dispBmp, 0, NULL);
	RETAILMSG(0, (_T("+ DRVESC_DISP_BITMAP %d\r\n"), nRet));

	delete [] dispBmp.pBuffer;
	CloseHandle(hFile);

	return TRUE;
}
Exemplo n.º 18
0
RESULT 
RippleEffect::Init()
{
    RETAILMSG(ZONE_RENDER, "RippleEffect::Init()");

    RESULT rval = S_OK;

    if (s_RippleShadersLoaded)
    {
        return S_OK;
    }

    CHR(OpenGLESEffect::Init());

    CHR(ShaderMan.CreateShader( "RippleEffect", s_RippleVertexShaderName, s_RippleFragmentShaderName, &s_hRippleShader ));
    
    // Save uniform handles.
    s_RippleShaderProgram = ShaderMan.GetShaderProgramID( s_hRippleShader );
    VERIFYGL(glUseProgram(s_RippleShaderProgram));

    VERIFYGL(s_uModelViewMatrix     = glGetUniformLocation(s_RippleShaderProgram, "uMatModelView"));
    VERIFYGL(s_uProjectionMatrix    = glGetUniformLocation(s_RippleShaderProgram, "uMatProjection"));
    VERIFYGL(s_uTexture             = glGetUniformLocation(s_RippleShaderProgram, "uTexture"));
    VERIFYGL(s_uGlobalColor         = glGetUniformLocation(s_RippleShaderProgram, "uGlobalColor"));
    VERIFYGL(s_uAmplitude           = glGetUniformLocation(s_RippleShaderProgram, "uAmplitude"));
    VERIFYGL(s_uTime                = glGetUniformLocation(s_RippleShaderProgram, "uTime"));
    VERIFYGL(s_uRadius              = glGetUniformLocation(s_RippleShaderProgram, "uRadius"));
    VERIFYGL(s_uOrigin              = glGetUniformLocation(s_RippleShaderProgram, "uOrigin"));
    VERIFYGL(s_uHalfWaveLength      = glGetUniformLocation(s_RippleShaderProgram, "uHalfWaveLength"));
    VERIFYGL(s_uNumWaves            = glGetUniformLocation(s_RippleShaderProgram, "uNumWaves"));
    VERIFYGL(s_uColor               = glGetUniformLocation(s_RippleShaderProgram, "uColor"));
    
    s_RippleShadersLoaded = true;

Exit:
    return rval;
}
Exemplo n.º 19
0
void INC_MSG_PRINTF(INC_INT8 nFlag, INC_INT8* pFormat, ...)
{
	va_list Ap;
	INC_UINT16 nSize;
	INC_INT8 acTmpBuff[256] = {0};

	va_start(Ap, pFormat);
	nSize = vsprintf(acTmpBuff, pFormat, Ap);
	va_end(Ap);

	//RETAILMSG(nFlag, (TEXT("%s"), wcstring));
#ifdef INC_KERNEL_SPACE
	if(nFlag)
		printk("%s", acTmpBuff);

#else
	printf("%s", acTmpBuff);

	//TODO Serial code here...
	///////////////////////////////////////////////////
	// .NET 버전일 경우 wchar_t로 변환
	INC_INT8 logstr[256] = {0};
	wchar_t wcstring[1024] = {0};
	mbstowcs(wcstring, acTmpBuff, strlen(acTmpBuff)+1);
	RETAILMSG(nFlag, (TEXT("%s"), wcstring));
	///////////////////////////////////////////////////
	if(m_hINC_LogFile && nFlag){
		SYSTEMTIME time;
		GetLocalTime(&time);

		sprintf(logstr, "[%02d.%02d %02d:%02d:%02d] %s",
			time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, acTmpBuff);

		fwrite(logstr, sizeof(char), strlen(logstr)+1, m_hINC_LogFile);
	}
#endif
}
Exemplo n.º 20
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// UnattendedMode Management
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SetUnattendedMode(BOOL bMode)
{
	HANDLE hWSMDrv = NULL;
	BOOL bRet = TRUE;
	DWORD dwBytesReturned = 0;


	if( !bInitCS )
	{
		InitializeCriticalSection(&g_csLock);
		bInitCS = TRUE;
	}
	EnterCriticalSection(&g_csLock);

	hWSMDrv = CreateFile(WIFI_SERVICE_MANAGER_DRIVER_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);


	if( hWSMDrv != INVALID_HANDLE_VALUE )
	{
		if( !DeviceIoControl(hWSMDrv, IOCTL_WIFISVCMGR_SET_UNATTENDEDMODE, &bMode, sizeof(bMode), NULL, 0, &dwBytesReturned, NULL) )
		{
			bRet = FALSE;
			RETAILMSG(1, (TEXT("[NETUI] SetUnattendedMode - DeviceIoControl Failed! \r\n") ));
		} 

		CloseHandle(hWSMDrv);
	}
	else
	{
		bRet = FALSE;
	}

	LeaveCriticalSection(&g_csLock);

	return bRet;

}
Exemplo n.º 21
0
RESULT
LayerManager::CreateLayer( IN const Settings* pSettings, IN const string& settingsPath, INOUT Layer** ppLayer )
{
    RESULT rval = S_OK;
    string name;
    
    if (!pSettings || "" == settingsPath || !ppLayer)
    {
        RETAILMSG(ZONE_ERROR, "ERROR: LayerManager::CreateLayer(): invalid argument");
        return E_INVALID_ARG;
    }
    
    Layer *pLayer = new Layer();
    CPR(pLayer);

    name = pSettings->GetString( settingsPath + ".Name" );
    pLayer->Init( name );

    // Caller must AddRef()
    *ppLayer = pLayer;
    
Exit:    
    return rval;
}
Exemplo n.º 22
0
RippleEffect::RippleEffect( const RippleEffect& rhs ) : 
    OpenGLESEffect(),
    m_pRippledVertices(NULL),
    m_numRippledVertices(0),
    m_rows(DEFAULT_ROWS),
    m_columns(DEFAULT_COLUMNS),
    m_padding(DEFAULT_PADDING),
    m_fWaveLength(DEFAULT_WAVE_LENGTH),
    m_fNumWaves(DEFAULT_NUM_WAVES),
    m_fAmplitude(DEFAULT_AMPLITUDE),
    m_fSpeed(DEFAULT_SPEED),
    m_fRadius(DEFAULT_RADIUS),
    m_color(DEFAULT_COLOR),
    m_origin(0,0)
{
    RETAILMSG(ZONE_OBJECT | ZONE_VERBOSE, "RippleEffect( %4d ) (copy ctor)", m_ID);

    ATOMIC_INCREMENT( RippleEffect::s_NumInstances );

    m_name = "RippleEffect";
    memset(&m_frame, 0, sizeof(m_frame));

    *this = rhs;
}
Exemplo n.º 23
0
void	C_DM9000::EDeviceRegisterIoSpace(void)
{
	NIC_DEVICE_OBJECT::EDeviceRegisterIoSpace();
	
	U32	val;
	
	val  = DeviceReadPort(0x2a);
	val |= DeviceReadPort(0x2b)<<8;
	val |= DeviceReadPort(0x28)<<16;
	val |= DeviceReadPort(0x29)<<24;

	DEBUG_PRINT((
		TEXT("[dm9: Chip signature is %08X\r\n"), val
		));

	RETAILMSG(1, (TEXT("[dm9: Chip signature is %08X\r\n"), val));
	
	if( (DeviceReadPort(DM9_VIDL) != LOW_BYTE(DM9000_VID)) ||
		(DeviceReadPort(DM9_VIDH) != HIGH_BYTE(DM9000_VID)) ||
		(DeviceReadPort(DM9_PIDL) != LOW_BYTE(DM9000_PID)) ||
		(DeviceReadPort(DM9_PIDH) != HIGH_BYTE(DM9000_PID)) )
		THROW((ERR_STRING("Unknown device")));

}
Exemplo n.º 24
0
GPIODriver::GPIODriver()
{
	if(hGpio == INVALID_HANDLE_VALUE)
		hGpio = CreateFile(GPIO_DEVICE_NAME, GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
	
	if (hGpio == INVALID_HANDLE_VALUE)
	{
		RETAILMSG(1,(TEXT("Failed open gioD: device driver!\r\n")));
	}

	
    // Allocate memory for our handler...
    pContext = (DEVICE_CONTEXT_GPIO*)LocalAlloc(
        LPTR, sizeof(DEVICE_CONTEXT_GPIO)
        );
    if (pContext == NULL)
        {
        DEBUGMSG(1, (L"GPIOOpen LocalAlloc failed\r\n"));
        CloseHandle(hGpio);
        }
    // Save device handle
    pContext->hDevice = hGpio;

}
Exemplo n.º 25
0
DWORD GIO_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
	// depending on Single or Bulk mode, returns status of GPIO(s)[High/Low]
	DWORD value=~0;
	if(bulk_active)
	{
		for(int n=0;n<16;n++)
		{
			value |= ((getDatum(n)==1)?1:0)<<n;
		}
	}
	else
	{
		value=getDatum(active_port);
	}
	if(Count!=4)
	{
		RETAILMSG(DEBUG_GPIO, (TEXT("GPIO_Control: GPIO_Read needs four buffer bytes ( sizeof(DWORD) )\r\n")));
		return FALSE;
	}
	*(DWORD *)pBuffer =value;
	
	return TRUE;
}
Exemplo n.º 26
0
BOOL SizeImg_Write(SIZE_IMG_IDX size_idx, unsigned char *pImg, int width, int height, int x_pos, int y_pos)
{
    int   i;    // Loop counter

    unsigned short *p_size_img;

    if ((height < SIZE_IMG_HEIGHT) || (width < SIZE_IMG_WIDTH))
        return FALSE;

    pImg += ((y_pos * width) << 1);

    switch (size_idx) {
    case SIZE_IMG_QVGA:     // QVGA
    case SIZE_IMG_VGA:      // VGA
    case SIZE_IMG_SD:       // SD
        break;

    case SIZE_IMG_UNDEF:    // undef
        return FALSE;

    default:
        RETAILMSG(1,(L"\nInvalid size_val value, %d\n", size_idx));
        return FALSE;
    }

    p_size_img = size_img[size_idx];
    pImg += (x_pos << 1);
    for (i=0; i<SIZE_IMG_HEIGHT; i++) {
        memcpy(pImg, p_size_img, SIZE_IMG_WIDTH*2);
        p_size_img += SIZE_IMG_WIDTH;
        pImg += (width << 1);
    }


    return TRUE;
}
Exemplo n.º 27
0
/*
** Function Name : MFC_IOControl
**
** Function Description : This function support any process of MFC instance.
*/
BOOL
MFC_IOControl(
    DWORD OpenHandle,
    DWORD dwIoControlCode,
    PBYTE pInBuf,
    DWORD nInBufSize,
    PBYTE pOutBuf,
    DWORD nOutBufSize,
    PDWORD pBytesReturned
    )
{
    MFC_HANDLE  *handle;
    MFCInstCtx     *pMfcInst;
    MFC_ARGS      *args;

    int ret                       = MFCINST_RET_OK;
    unsigned char  *p_buf         = NULL;
    int n_bufsize                 = 0;
    PVOID pMarshalledInBuf        = NULL;
    static CEDEVICE_POWER_STATE   mfc_pwr_state;
  
    BOOL    result = TRUE;

    handle = (MFC_HANDLE *) OpenHandle;

    /////////////////////
    // Parameter Check //
    /////////////////////
    if (handle == NULL)
    {
        LOG_MSG(LOG_TRACE, "MFC_IOControl", "OpenHandle == NULL\n");
        return FALSE;
    }

    if (handle != gMfcHandlePower)
    {
        if (pInBuf == NULL)
        {
            LOG_MSG(LOG_TRACE, "MFC_IOControl", "pInBuf == NULL\n");
            return FALSE;
        }
        if (nInBufSize == 0)
        {
            LOG_MSG(LOG_TRACE, "MFC_IOControl", "nInBufSize == 0\n");
            return FALSE;
        }

        if ((pOutBuf != NULL) || (nOutBufSize != 0) || (pBytesReturned != NULL))
        {
            LOG_MSG(LOG_TRACE, "MFC_IOControl", "others.....\n");
            return FALSE;
        }
    }

    pMfcInst = handle->mfc_inst;

    MFC_Mutex_Lock();

    switch ( dwIoControlCode )
    {
    case IOCTL_POWER_CAPABILITIES:
        {
            RETAILMSG(1, (L"[MFC IOCTL_POWER_CAPABILITIES]\n"));

            PPOWER_CAPABILITIES ppc;

            if ( !pBytesReturned || !pOutBuf || (nOutBufSize < sizeof(POWER_CAPABILITIES)) ) {
                SetLastError (ERROR_INVALID_PARAMETER);
                MFC_Mutex_Release();
                return FALSE;
            }
            
            __try
            {
                ppc = (PPOWER_CAPABILITIES)pOutBuf;
                memset(ppc, 0, sizeof(POWER_CAPABILITIES));

                // support D0, D4
                ppc->DeviceDx = DX_MASK(D0) | DX_MASK(D4);

                // no wake
                // no inrush

                // Report our nominal power consumption in uAmps rather than mWatts.
                ppc->Flags = POWER_CAP_PREFIX_MICRO | POWER_CAP_UNIT_AMPS;

                *pBytesReturned = sizeof(POWER_CAPABILITIES);

                RETAILMSG(1, (L"[MFC IOCTL_POWER_CAPABILITIES] leaving...\n"));
            }
            __except(EXCEPTION_EXECUTE_HANDLER)
            {
                RETAILMSG(1, (L"[MFC IOCTL_POWER_CAPABILITIES] exception...\n"));
                MFC_Mutex_Release();
                return FALSE;
            }
            break;
        }

    case IOCTL_POWER_SET:
        CEDEVICE_POWER_STATE NewDx;

        //if caller is not kernel mode, do not allow setting power state
        if (GetDirectCallerProcessId() != GetCurrentProcessId())
        {
            RETAILMSG(1, (L"[MFC IOCTL_POWER_SET] User mode access denied\r\n"));
            MFC_Mutex_Release();
            return ERROR_ACCESS_DENIED;
        }

        __try
        {
            if (pOutBuf == NULL)
            {
                return FALSE;
            }
            
            NewDx = *(PCEDEVICE_POWER_STATE) pOutBuf;
            switch ( NewDx )
            {
            case D0:    // Power Up
                    *(PCEDEVICE_POWER_STATE)pOutBuf = process_MFC_PowerUp(OpenHandle, &mfc_pwr_state);
                break;

            case D4:    // Power Down
                    *(PCEDEVICE_POWER_STATE)pOutBuf = process_MFC_PowerDown(OpenHandle, &mfc_pwr_state);
                break;

            default:
                MFC_Mutex_Release();
                return FALSE;
            }

            *pBytesReturned = sizeof(CEDEVICE_POWER_STATE);
        }
        __except(EXCEPTION_EXECUTE_HANDLER)
        {
            RETAILMSG(1, (L"[MFC IOCTL_POWER_SET] exception...\n"));
            MFC_Mutex_Release();
            return FALSE;
        }

        break;

    case IOCTL_MFC_MPEG4_ENC_INIT:
    case IOCTL_MFC_H264_ENC_INIT:
    case IOCTL_MFC_H263_ENC_INIT:
        {
            MFC_CODECMODE   codec_mode;
            enc_info_t      enc_info;

            if (dwIoControlCode == IOCTL_MFC_MPEG4_ENC_INIT)
                codec_mode = MP4_ENC;
            else if (dwIoControlCode == IOCTL_MFC_H264_ENC_INIT)
                codec_mode = AVC_ENC;
            else
                codec_mode = H263_ENC;

            if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
            {
                RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_H263_ENC_INIT.\r\n")));
                MFC_Mutex_Release();
                return FALSE;
            }

            args = (MFC_ARGS *)pMarshalledInBuf;

            // Input arguments for IOCTL_MFC_xxx_ENC_INIT
            enc_info.width        = args->enc_init.in_width;
            enc_info.height        = args->enc_init.in_height;
            enc_info.frameRateRes    = args->enc_init.in_frameRateRes;
            enc_info.frameRateDiv    = args->enc_init.in_frameRateDiv;
            enc_info.gopNum        = args->enc_init.in_gopNum;
            enc_info.bitrate        = args->enc_init.in_bitrate;

            enc_info.intraqp        = args->enc_init.in_intraqp;
            enc_info.qpmax        = args->enc_init.in_qpmax;
            enc_info.gamma        = args->enc_init.in_gamma;

            ///////////////////////////////////
            ///   Initialize MFC Instance   ///
            ///////////////////////////////////
            Mfc_Clk_On();
            ret = MFCInst_Enc_Init(pMfcInst, codec_mode, &enc_info);
            Mfc_Clk_Off();

            // Output arguments for IOCTL_MFC_xxx_ENC_INIT
            args->enc_init.ret_code = ret;

            if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
            {
                RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_H263_ENC_INIT.\r\n")));
                MFC_Mutex_Release();
                return FALSE;
            }

            break;
        }

    case IOCTL_MFC_MPEG4_ENC_EXE:
    case IOCTL_MFC_H264_ENC_EXE:
    case IOCTL_MFC_H263_ENC_EXE:
        {
            int nStrmLen, nHdrLen;
            if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
            {
                RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_H263_ENC_EXE.\r\n")));
                MFC_Mutex_Release();
                return FALSE;
            }

            args = (MFC_ARGS *)pMarshalledInBuf;
            MFCInst_GetFramBuf(pMfcInst, &p_buf, &n_bufsize);
            CleanInvalidateCacheRange((PBYTE )p_buf, (PBYTE )(p_buf + n_bufsize) );
            
            // nStrmLen is size of output stream data
            Mfc_Clk_On();
            ret = MFCInst_Encode(pMfcInst, &nStrmLen, &nHdrLen);
            Mfc_Clk_Off();

            MFCInst_GetLineBuf(pMfcInst, &p_buf, &n_bufsize);
            InvalidateCacheRange((PBYTE )p_buf, (PBYTE )(p_buf + n_bufsize) );
        
            // Output arguments for IOCTL_MFC_xxx_ENC_EXE
            args->enc_exe.ret_code = ret;
            if (ret == MFCINST_RET_OK) {
                args->enc_exe.out_encoded_size = nStrmLen;
                args->enc_exe.out_header_size  = nHdrLen;
            }

            if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
            {
                RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_H263_ENC_EXE.\r\n")));
                MFC_Mutex_Release();
                return FALSE;
            }

            break;
        }

    case IOCTL_MFC_MPEG4_DEC_INIT:
    case IOCTL_MFC_H263_DEC_INIT:
    case IOCTL_MFC_H264_DEC_INIT:
    case IOCTL_MFC_VC1_DEC_INIT:
        {
            MFC_CODECMODE   codec_mode;

            if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
            {
                RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_VC1_DEC_INIT.\r\n")));
                MFC_Mutex_Release();
                return FALSE;
            }

            args = (MFC_ARGS *)pMarshalledInBuf;

            if (dwIoControlCode == IOCTL_MFC_MPEG4_DEC_INIT) {
                codec_mode = MP4_DEC;
            }
            else if (dwIoControlCode == IOCTL_MFC_H263_DEC_INIT) {
                codec_mode = MP4_DEC;
            }
            else if (dwIoControlCode == IOCTL_MFC_H264_DEC_INIT) {
                codec_mode = AVC_DEC;
            }
            else {
                codec_mode = VC1_DEC;
            }

            /////////////////////////////////
            //   Initialize MFC Instance   //
            /////////////////////////////////
            Mfc_Clk_On();
            ret = MFCInst_Dec_Init(pMfcInst, codec_mode, args->dec_init.in_strmSize);
            Mfc_Clk_Off();

            // Output arguments for IOCTL_MFC_xxx_DEC_INIT
            args->dec_init.ret_code = ret;
            if (ret == MFCINST_RET_OK) {
                args->dec_init.out_width  = pMfcInst->width;
                args->dec_init.out_height = pMfcInst->height;
            }

            if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
            {
                RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_VC1_DEC_INIT.\r\n")));
                MFC_Mutex_Release();
                return FALSE;
            }

            break;
        }

    case IOCTL_MFC_MPEG4_DEC_EXE:
    case IOCTL_MFC_H263_DEC_EXE:
    case IOCTL_MFC_H264_DEC_EXE:
    case IOCTL_MFC_VC1_DEC_EXE:

        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_VC1_DEC_EXE.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        args = (MFC_ARGS *)pMarshalledInBuf;

        MFCInst_GetLineBuf(pMfcInst, &p_buf, &n_bufsize);
        CleanInvalidateCacheRange((PBYTE )p_buf, (PBYTE )(p_buf + n_bufsize) );

        Mfc_Clk_On();
        ret = MFCInst_Decode(pMfcInst, args->dec_exe.in_strmSize);
        Mfc_Clk_Off();

        // Output arguments for IOCTL_MFC_xxx_DEC_EXE
        args->dec_exe.ret_code = ret;

        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_VC1_DEC_EXE.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        break;


    case IOCTL_MFC_GET_LINE_BUF_ADDR:

        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_GET_LINE_BUF_ADDR.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        args = (MFC_ARGS *)pMarshalledInBuf;

        ret = MFCInst_GetLineBuf(pMfcInst, &p_buf, &n_bufsize);
        if (ret != MFCINST_RET_OK) 
        {
            goto GetLineBuffCleanup;
        }
        
        if (handle->pStrmBuf == NULL)
        {
            // Map the Line buffer for this instance to the caller's address space
            //
            handle->hUsrProc = (HANDLE) GetDirectCallerProcessId();
            handle->pStrmBuf = (PBYTE) VirtualAllocEx(handle->hUsrProc, 
                                                        NULL,
                                                        n_bufsize, 
                                                        MEM_RESERVE, 
                                                        PAGE_NOACCESS);
            if (handle->pStrmBuf == NULL)
            {
                RETAILMSG(1, (L"DD::MFC VirtualAllocEx(pStrmBuf) returns FALSE.\n"));
                ret = MFCINST_ERR_MEMORY_ALLOCATION_FAIL;
                goto GetLineBuffCleanup;
            }
            result = VirtualCopyEx(handle->hUsrProc,
                                   handle->pStrmBuf,
                                   (HANDLE) GetCurrentProcessId(),
                                   p_buf,
                                   n_bufsize,
                                   PAGE_READWRITE );
            if (result == FALSE){
                RETAILMSG(1, (L"DD::MFC VirtualCopyEx(pStrmBuf) returns FALSE.\n"));
                VirtualFreeEx(handle->hUsrProc, handle->pStrmBuf, 0, MEM_RELEASE);
                handle->pStrmBuf = NULL;
                ret = MFCINST_ERR_MEMORY_ALLOCATION_FAIL;
                goto GetLineBuffCleanup;
            }
        }

        // Output arguments for IOCTL_MFC_GET_FRAM_BUF_ADDR
        args->get_buf_addr.out_buf_size   = n_bufsize;
        args->get_buf_addr.out_buf_addr   = (int) handle->pStrmBuf;


GetLineBuffCleanup:

        args->get_buf_addr.ret_code = ret;
        
        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_GET_LINE_BUF_ADDR.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        break;

    case IOCTL_MFC_GET_FRAM_BUF_ADDR:

        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_GET_FRAM_BUF_ADDR.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        args = (MFC_ARGS *)pMarshalledInBuf;

        // Decoder case
        ret = MFCInst_GetFramBuf(pMfcInst, &p_buf, &n_bufsize);
        if (ret != MFCINST_RET_OK) 
        {
            goto GetFrameBuffCleanup;
        }

        // Check Paramter
        if (pMfcInst->run_index * n_bufsize < 0 ||
            (pMfcInst->run_index * n_bufsize) > (int)(pMfcInst->nFramBufSize))
        {
            RETAILMSG(1, (L"[MFC ERROR] IOCTL_MFC_GET_FRAM_BUF_ADDR: Run Index out of range.\r\n"));
            ret = MFCINST_ERR_ETC;
            goto GetFrameBuffCleanup;
        }
        
        if (handle->pFramBuf == NULL)
        {
            // Map the Frame buffer for this instance to the caller's address space
            //
            handle->hUsrProc = (HANDLE) GetDirectCallerProcessId();
            handle->pFramBuf = (PBYTE) VirtualAllocEx(handle->hUsrProc, 
                                                      NULL,
                                                      pMfcInst->nFramBufSize, 
                                                      MEM_RESERVE, 
                                                      PAGE_NOACCESS);
            if (handle->pFramBuf == NULL)
            {
                RETAILMSG(1, (L"DD::MFC VirtualAllocEx(pFramBuf) returns FALSE.\n"));
                ret = MFCINST_ERR_MEMORY_ALLOCATION_FAIL;
                goto GetFrameBuffCleanup;
            }

            result= VirtualCopyEx(handle->hUsrProc,       // HANDLE hDstProc
                                  handle->pFramBuf,
                                  (HANDLE) GetCurrentProcessId(),     // HANDLE hSrcProc
                                  pMfcInst->pFramBuf,
                                  pMfcInst->nFramBufSize,
                                  PAGE_READWRITE);
            if (result == FALSE)
            {
                RETAILMSG(1, (L"DD::MFC VirtualCopyEx(pFramBuf) returns FALSE.\n"));
                VirtualFreeEx(handle->hUsrProc, handle->pFramBuf, 0, MEM_RELEASE);
                handle->pFramBuf = NULL;
                ret = MFCINST_ERR_MEMORY_ALLOCATION_FAIL;
                goto GetFrameBuffCleanup;
            }
        }

        if (pMfcInst->run_index >= 0)
        {
            args->get_buf_addr.out_buf_addr  = (int) (handle->pFramBuf + (pMfcInst->run_index * n_bufsize));

#if (MFC_ROTATE_ENABLE == 1)
            // If PostRotMode is enabled, then the output YUV buffer will be different.
            // In VC-1 mode, the rotated output will be the original one.
            if ( (pMfcInst->codec_mode != VC1_DEC) && (pMfcInst->PostRotMode & 0x0010) )
            {
                args->get_buf_addr.out_buf_addr = (int) (handle->pFramBuf + (pMfcInst->frambufCnt * n_bufsize));
            }
#endif
        }
        else
        {
            args->get_buf_addr.out_buf_addr  = 0;
        }
        
        args->get_buf_addr.out_buf_size   = n_bufsize;
        
GetFrameBuffCleanup:

        args->get_buf_addr.ret_code = ret;
        
        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_GET_FRAM_BUF_ADDR.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        break;

    case IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR:

        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        args = (MFC_ARGS *)pMarshalledInBuf;

        // Decoder case
        ret = MFCInst_GetFramBufPhysical(pMfcInst, &p_buf, &n_bufsize);

        // Output arguments for IOCTL_MFC_xxx_DEC_EXE
        args->get_buf_addr.ret_code = ret;

        if (ret == MFCINST_RET_OK) 
        { 
            // Output arguments for IOCTL_MFC_GET_FRAM_BUF_ADDR
            args->get_buf_addr.out_buf_addr   = (int) p_buf;
            args->get_buf_addr.out_buf_size   = n_bufsize;
        }

        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        break;

    case IOCTL_MFC_GET_MPEG4_ASP_PARAM:

        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_GET_MPEG4_ASP_PARAM.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        args = (MFC_ARGS *)pMarshalledInBuf;

#if (defined(DIVX_ENABLE) && (DIVX_ENABLE == 1))
        ret = MFCINST_RET_OK;
        args->mpeg4_asp_param.ret_code              = MFCINST_RET_OK;
        args->mpeg4_asp_param.mp4asp_vop_time_res   = pMfcInst->RET_DEC_SEQ_INIT_BAK_MP4ASP_VOP_TIME_RES;
        args->mpeg4_asp_param.byte_consumed         = pMfcInst->RET_DEC_PIC_RUN_BAK_BYTE_CONSUMED;
        args->mpeg4_asp_param.mp4asp_fcode          = pMfcInst->RET_DEC_PIC_RUN_BAK_MP4ASP_FCODE;
        args->mpeg4_asp_param.mp4asp_time_base_last = pMfcInst->RET_DEC_PIC_RUN_BAK_MP4ASP_TIME_BASE_LAST;
        args->mpeg4_asp_param.mp4asp_nonb_time_last = pMfcInst->RET_DEC_PIC_RUN_BAK_MP4ASP_NONB_TIME_LAST;
        args->mpeg4_asp_param.mp4asp_trd            = pMfcInst->RET_DEC_PIC_RUN_BAK_MP4ASP_MP4ASP_TRD;

#if (_WIN32_WCE >= 600)
        if (handle->pFramBuf != NULL){
            args->mpeg4_asp_param.mv_addr      = ((unsigned int) handle->pFramBuf) + (pMfcInst->mv_mbyte_addr - pMfcInst->phyadrFramBuf);
            args->mpeg4_asp_param.mb_type_addr = args->mpeg4_asp_param.mv_addr + 25920;    
            args->mpeg4_asp_param.mv_size      = 25920; // '25920' is the maximum MV size (=45*36*16)
            args->mpeg4_asp_param.mb_type_size = 1620; // '1620' is the maximum MBTYE size (=45*36*1)
        }
#else
        args->mpeg4_asp_param.mv_addr      = ((unsigned int) pMfcInst->pFramBuf) + (pMfcInst->mv_mbyte_addr - pMfcInst->phyadrFramBuf);
        args->mpeg4_asp_param.mb_type_addr = args->mpeg4_asp_param.mv_addr + 25920;    
        args->mpeg4_asp_param.mv_size      = 25920;
        args->mpeg4_asp_param.mb_type_size = 1620;
#endif

        InvalidateCacheRange((PBYTE )args->mpeg4_asp_param.mv_addr, (PBYTE )(args->mpeg4_asp_param.mv_addr + args->mpeg4_asp_param.mv_size) );
        InvalidateCacheRange((PBYTE )args->mpeg4_asp_param.mb_type_addr , (PBYTE )(args->mpeg4_asp_param.mb_type_addr  + args->mpeg4_asp_param.mb_type_size) );
#endif

        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_GET_MPEG4_ASP_PARAM.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }

        break;

    case IOCTL_MFC_GET_CONFIG:
        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_GET_CONFIG.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }
        args = (MFC_ARGS *)pMarshalledInBuf;

        ret = MFC_GetConfigParams(pMfcInst, args);

        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_GET_CONFIG.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }
        break;

    case IOCTL_MFC_SET_CONFIG:
        if(FAILED(CeOpenCallerBuffer(&pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR, TRUE)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeOpenCallerBuffer failed in IOCTL_MFC_SET_CONFIG.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }
        args = (MFC_ARGS *)pMarshalledInBuf;

        Mfc_Clk_On();
        ret = MFC_SetConfigParams(pMfcInst, args);
        Mfc_Clk_Off();

        if(FAILED(CeCloseCallerBuffer(pMarshalledInBuf, pInBuf, nInBufSize, ARG_IO_PTR)))
        {
            RETAILMSG(1, (TEXT("MFC_IOControl: CeCloseCallerBuffer failed in IOCTL_MFC_SET_CONFIG.\r\n")));
            MFC_Mutex_Release();
            return FALSE;
        }
        break;

    default:
        RETAILMSG(1, (L"[MFC IOControl] Requested ioctl command is not defined. (ioctl cmd=0x%X)\n", dwIoControlCode));
        MFC_Mutex_Release();
        return FALSE;
    }

    MFC_Mutex_Release();

    switch (ret)
    {
    case MFCINST_RET_OK:
        return TRUE;
    default:
        return FALSE;
    }
    return FALSE;
}
Exemplo n.º 28
0
// This is the task-bar wndproc. 
LRESULT CALLBACK TaskBarWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	DEBUGMSG(ZONE_TRACEMSGHF, (TEXT("Taskbar Window Msg=%x wp=%x lp=%x\r\n"), msg, wp, lp));

	switch(msg)
	{
		// 5sec housekeeping timer
		case WM_TIMER:
			DoHibernate(); // check free-memory level & notify apps if neccesary
			DoPowerCheck(hwnd); // check battery levels & pop-up warning if reqd
			break;

		case WM_SYSKEYDOWN:
		case WM_KEYDOWN:
		{
			DEBUGMSG(ZONE_TRACEMSG, (TEXT("Taskbar Window WM_KEYDOWN\r\n")));
			// For now we're sending Ctrl-Esc, Alt-Esc, Alt-Tab, Ctrl-Alt-Del/Bksp all to TaskMan
			// A fuller shell would implement a Start-Menu on Alt-Esc for example.
			switch (wp) 
			{
				case VK_DELETE:
				case VK_BACK:
					// Send Ctrl-Alt-Bksp to Taskman. NOTE: GWES doesn't send us Ctrl-Alt-Del
					DEBUGMSG(ZONE_TRACEMSG, (TEXT("Taskbar Window WM_KEYDOWN, VK_BACK or VK_DELETE\r\n")));
					if (GetKeyState(VK_CONTROL) && GetKeyState(VK_MENU)) 
						Show_TaskMan();
					break;

				case VK_TAB:
					// Send Alt-Tab to TaskMan
					DEBUGMSG(ZONE_TRACEMSG, (TEXT("Taskbar Window WM_KEYDOWN, VK_TAB\r\n")));
					if (GetKeyState(VK_MENU)) 
						Show_TaskMan();
					break;
					
				case VK_ESCAPE:
					// Send Ctrl-Esc & Alt-Esc to TaskMan
					DEBUGMSG(ZONE_TRACEMSG, (TEXT("Taskbar Window WM_KEYDOWN, VK_ESCAPE\r\n")));
					if(GetKeyState(VK_CONTROL) || GetKeyState(VK_MENU))
						Show_TaskMan();
					break;

				default:
					return DefWindowProc(hwnd, msg, wp, lp);
			}
		}
		break;
		case WM_HANDLESHELLNOTIFYICON:
			// Private message posted by the callback in minserver.cpp when it
			// gets a Shell_NotifyIcon call. wParam is NIM_ADD/DELETE etc
			// lParam is a PNOTIFYICONDATA (we are responsible for freeing)
			// For now just print a debug message to show we got the data 
			// correctly.
			PNOTIFYICONDATA pnid;
			pnid = (PNOTIFYICONDATA)lp;
			RETAILMSG(1, (L"got Shell_NotifyIcon(nim=%d, nid(hwnd=0x%08x uId=%d uFlags=%d uCBMsg=%d hIcon=0x%08x, szTip=%s\r\n",
				wp, pnid->hWnd, pnid->uID, pnid->uFlags, pnid->uCallbackMessage, pnid->hIcon, (pnid->szTip ? pnid->szTip : L"null")));
			// ----- Insert real processing of this API here -----
			MyFree(pnid);
			break;
			
		case WM_HANDLESHADDTORECENTDOCS:
			// Private message posted by the callback in minserver.cpp when it
			// gets a SHAddToRecentDocs call. wParam is SHARD_PATH
			// lParam is a the path (we are responsible for freeing)
			// For now just print a debug message to show we got the data 
			// correctly
			RETAILMSG(1, (L"got SHAddToRecentDocs(uFlags=%d, path=%s)\r\n", wp, (lp ? (PTSTR)lp : L"null")));
			// ----- Insert real processing of this API here -----
			MyFree((PVOID)lp);
			break;

		default:
			// This window will get GWE messages on window-create/delete etc. 
			// If it wants to display Win9x/NT-like task buttons etc., it 
			// should handle these messages
			return DefWindowProc(hwnd, msg, wp, lp);
	}
	return 0;
}
Exemplo n.º 29
0
/*
** Function Name : MFC_Open
**
** Function Description : This function open MFC instace and return instance handle.
*/
DWORD
MFC_Open(
    DWORD InitHandle,
    DWORD dwAccess,
    DWORD dwShareMode
    )
{
    MFC_HANDLE   *handle;

    // Mutex Lock
    MFC_Mutex_Lock();

    // Allocate & Clear MFC Handle
    handle = (MFC_HANDLE *) malloc(sizeof(MFC_HANDLE));
    if (!handle)
    {
        RETAILMSG(1, (L"\n[MFC_Open Error] Momory Allocation Fail.\n"));
        MFC_Mutex_Release();
        return 0;
    }
    memset(handle, 0, sizeof(MFC_HANDLE));

    // Increment OpenHandle Count
    InterlockedIncrement(&_openhandle_count);

    //
    if (_openhandle_count == 1) // Handle for Power Control
    {
        // Save Specific Handle for Power Control
        gMfcHandlePower = handle;
        RETAILMSG(1, (L"\n[MFC_Open] Power Manager Handle Opened...\n"));
    }
    else if (_openhandle_count >= 2) // Handle for User Application
    {
        // Create MFC Instance
        handle->mfc_inst = MFCInst_Create();
        if (!handle->mfc_inst)
        {
            RETAILMSG(1, (L"\n[MFC_Open Error] MFC Instance Creattion Fail.\n"));
            InterlockedDecrement(&_openhandle_count);
            free(handle);
            MFC_Mutex_Release();
            return 0;
        }

        if (_openhandle_count == 2) // First Handle for User Application
        {
            // MFC HW Init
            Mfc_Pwr_On();
            Mfc_Clk_On();

            if (MFC_HW_Init() == FALSE)
            {
                Mfc_Clk_Off();
                Mfc_Pwr_Off();
                MFCInst_Delete(handle->mfc_inst);
                InterlockedDecrement(&_openhandle_count);
                MFC_Mutex_Release();
                return 0;
            }
            Mfc_Clk_Off();
        }
    }

    // Mutex Release
    MFC_Mutex_Release();

    return (DWORD) handle;
}
Exemplo n.º 30
0
/********************************************************************************
//ACLineStatus -- 0 Offline  1 Online  255 Unknown status 
//
//
//*******************************************************************************/
BOOL WINAPI
BatteryPDDGetStatus(
    PSYSTEM_POWER_STATUS_EX2 pstatus,  PBOOL pfBatteriesChangedSinceLastCall)
{
    BOOL fOk = TRUE;
    SYSTEM_POWER_STATUS_EX2 sps;
    BOOL ACStatus=FALSE;
    UCHAR ucBatteryPer = 0;
    UINT32 BATTERY_AUTOSLEEP_VOLTAGE_PERCENT ;
    UINT32 PERCENT_CRITICAL2LOW;

    BATTERY_AUTOSLEEP_VOLTAGE_PERCENT= 	( (g_stBattParam.u32AutoSleepVbat - BATTERY_MIN_VOLTAGE)* 100/(BATTERY_MAX_VOLTAGE - BATTERY_MIN_VOLTAGE)+1) ;
    PERCENT_CRITICAL2LOW	= BATTERY_AUTOSLEEP_VOLTAGE_PERCENT + 4;

    DPNOK(BATTERY_AUTOSLEEP_VOLTAGE_PERCENT);	
    DPNOK(PERCENT_CRITICAL2LOW);	
   
    SETFNAME(_T("BatteryPDDGetStatus"));

    RETAILMSG(ZONE_REG_PRINT, (TEXT("+BatteryPDDGetStatus...  \r\n")));
  
    DEBUGCHK(pstatus != NULL);
    DEBUGCHK(pfBatteriesChangedSinceLastCall != NULL);

    /* Fill 	ACLineStatus part */
    sps.ACLineStatus          = AC_LINE_UNKNOWN;	
    if(BspGetACStatus())
    {
        sps.ACLineStatus          = AC_LINE_ONLINE;
    }
    else
    {
        sps.ACLineStatus          = AC_LINE_OFFLINE;
    }

    /* Fill Battery status part */
    battery_status = BspGetBatteryFlag();

    if (PDD_NO_BATTERY == battery_status )
    {
        BspNotifyLed(FALSE);
        sps.BatteryFlag  = BATTERY_FLAG_NO_BATTERY;
        sps.BatteryLifePercent = BATTERY_PERCENTAGE_UNKNOWN;
    }
    else if (PDD_BATTERY_CHARGING == battery_status )
    {
        RETAILMSG(ZONE_REG_PRINT, (TEXT("+Battery status PDD_BATTERY_CHARGING...  \r\n"))); 
        BspFuelGaugeResetBatStatusInPercent();	   
        BspNotifyLed(FALSE);
        sps.BatteryFlag  = BATTERY_FLAG_CHARGING;
        sps.BatteryLifePercent = BATTERY_PERCENTAGE_UNKNOWN;
//  //[david.modify] 2008-05-31 14:49
// ڴ˴óʱҲʾٷֱ
//=======================================================
	   if(CHARGING_BIT&g_stBattParam.u32Debug) {
          ucBatteryPer = BspFuelGaugeGetBatStatusInPercent();

            if(ucBatteryPer >= PERCENT_CRITICAL2LOW)
            {
                sps.BatteryFlag  = BATTERY_FLAG_HIGH;
  	         BspNotifyLed(FALSE);
            }		 
            else if (( ucBatteryPer <PERCENT_CRITICAL2LOW) && (ucBatteryPer >=BATTERY_AUTOSLEEP_VOLTAGE_PERCENT))
            {
                 sps.BatteryFlag  = BATTERY_FLAG_LOW;
		   BspNotifyLed(TRUE);		 
            }		
            else if(ucBatteryPer<=BATTERY_AUTOSLEEP_VOLTAGE_PERCENT)
            {
                 sps.BatteryFlag  = BATTERY_FLAG_CRITICAL;
		   BspNotifyLed(TRUE);	
            }
            sps.BatteryLifePercent = 	ucBatteryPer;
	   }
//=======================================================		

		
    }
    else	
    {
        if(PDD_BATTERY_EOC == battery_status)
        {
            RETAILMSG(0, (TEXT("+Battery status PDD_BATTERY_EOC...  \r\n"))); 
            BspFuelGaugeResetBatStatusInPercent();	   
            BspNotifyLed(FALSE);
            sps.BatteryFlag  = BATTERY_FLAG_HIGH;
            sps.BatteryLifePercent =  100;
        } //end if PDD_BATTERY_EOC == battery_status
        else 
        {
            RETAILMSG(0, (TEXT("+Get Battery status PDD_BATTERY_ON...  \r\n"))); 
            ucBatteryPer = BspFuelGaugeGetBatStatusInPercent();

            if(ucBatteryPer >= PERCENT_CRITICAL2LOW)
            {
            ///// //Awisc.Chen add 2008-07-14 18:36 start
            #if 0//awisc add for test
            	  DPSTR("ucBatteryPer >= 20");
                 sps.BatteryFlag  = BATTERY_FLAG_CRITICAL;
		   BspNotifyLed(TRUE);	
		    //[david.modify] 2008-05-31 14:39
		   if(g_stBattParam.u32LowPowerSleep) {
		   	BspBattCriticalLow();}
		#endif
		///// //Awisc.Chen add 2008-07-14 18:35 end
                sps.BatteryFlag  = BATTERY_FLAG_HIGH; //Awisc.Chen delete 2008-07-14 18:36
  	         BspNotifyLed(FALSE); //Awisc.Chen delete 2008-07-14 18:36
            }		 
            else if (( ucBatteryPer <PERCENT_CRITICAL2LOW) && (ucBatteryPer >=BATTERY_AUTOSLEEP_VOLTAGE_PERCENT))
            {
                 sps.BatteryFlag  = BATTERY_FLAG_LOW;
		   BspNotifyLed(TRUE);		 
            }		
            else if(ucBatteryPer<=BATTERY_AUTOSLEEP_VOLTAGE_PERCENT) 
            {
            	  DPSTR("BATTERY_FLAG_CRITICAL");
                 sps.BatteryFlag  = BATTERY_FLAG_CRITICAL;
		   BspNotifyLed(TRUE);	
		    //[david.modify] 2008-05-31 14:39
		   if(g_stBattParam.u32LowPowerSleep) {
		   	BspBattCriticalLow();
		   }
            }
            sps.BatteryLifePercent = 	ucBatteryPer;
        }	//end else PDD_BATTERY_ONLY 	
    }//end else  PDD_BATTERY_CHARGING == battery_status

    sps.Reserved1                  = 0;
    sps.BatteryLifeTime            = BATTERY_LIFE_UNKNOWN;
    sps.BatteryFullLifeTime        = BATTERY_LIFE_UNKNOWN;
	
    sps.Reserved2                  = 0;
    sps.BackupBatteryFlag          = BATTERY_FLAG_UNKNOWN;
    sps.BackupBatteryLifePercent   = 0;
    sps.Reserved3                  = 0;
    sps.BackupBatteryLifeTime      = BATTERY_LIFE_UNKNOWN;
    sps.BackupBatteryFullLifeTime  = BATTERY_LIFE_UNKNOWN;
	
    sps.BatteryChemistry           = BATTERY_CHEMISTRY_LIPOLY;
//  sps.BatteryVoltage             = (unsigned long) (voltage_percent * 4.1); ;
    sps.BatteryCurrent             = 0;
    sps.BatteryAverageCurrent      = 0;
    sps.BatteryAverageInterval     = 0;
    sps.BatterymAHourConsumed      = 0;
    sps.BatteryTemperature         = 0;//temperature;
    sps.BackupBatteryVoltage       = 0;

    memcpy(&gpStatus->sps, &sps, sizeof(gpStatus->sps));
    
    // get battery status information from the shared structure
    LockBattery();
    memcpy(pstatus, &gpStatus->sps, sizeof(*pstatus));
    *pfBatteriesChangedSinceLastCall = gpStatus->fChanged;
    if(*pfBatteriesChangedSinceLastCall) {
        gpStatus->fChanged = FALSE;		// reset changed flag if it's set
    }
    UnlockBattery();
    
    DEBUGMSG(ZONE_PDD, (_T("%s: returning %d\r\n"), TEXT(__FUNCTION__), fOk));
    return (fOk);
}