Ejemplo n.º 1
0
/*-------------------------------------------------------------------*/
void SVL_NumericKeyHandler(U8 val)
{
    static U8 numOfDigits = 0;
    static U8 prgNum      = 0;

    if(numOfDigits == 0)
    {
        GM_Printf("DIGIT:%i*\n", val);
        prgNum      = val;
        numOfDigits = 1;
    }
    else
    {
        numOfDigits = 1;
        GM_Printf("DIGIT:%i%i\n", prgNum, val);
        prgNum = prgNum*10 + val;
        if(prgNum>MaxNumServices)
            CurrentService = 0;
        else
            CurrentService = prgNum;
        GM_Printf("\ntune to: %i  %s\n", CurrentService,
                                            SvcList[CurrentService].name);
        GM_SVL_Tune(CurrentService);
        prgNum = 0;
        numOfDigits = 0;
    }
}
Ejemplo n.º 2
0
GERR GD_FE_DIB7070X_Open(U8 index, GD_FE_DEVICE_DATA_S* pDeviceData)
{
    GERR error = GD_OK; //Modified by David Cao 2008-07-30

    if (index >= GD_FE_MAX_NUM) return GD_ERR_BAD_PARAMETER;
    if (pDeviceData == NULL) return GD_ERR_BAD_PARAMETER;

    /* check device data */
    if (pDeviceData->pSystemParams == NULL) return GD_ERR_BAD_PARAMETER;
    if (pDeviceData->systemType != GD_FE_SYSTEM_TYPE_TERRESTRIAL) return GD_ERR_BAD_PARAMETER;

    /* store pointer to device data */
    pData[index] = pDeviceData;

    /* reset the dibcom chip */
    #if 0
    if (pDeviceData->ghwIndex >= 0)
    {
        #if defined(SMARTMPEG_C)
        error = GD_GPIO_Open(pDeviceData->ghwIndex, GD_GPIO_TYPE_OUTPUT_1, NULL,&pData[index]->handleI2C);
        #endif
        if(error != GD_OK)
        {
            #ifdef GD_FE_MB86667_DEBUG01
            GM_Printf("MB86667_Tune(%i) = 0x%X\n",index,(U32)error);
            #endif
            return(error);
        }
        GD_GPIO_Write(pData[index]->handleI2C, 1);
        FE_SleepTime(10);
        GD_GPIO_Write(pData[index]->handleI2C, 0);
        FE_SleepTime(10);
        GD_GPIO_Write(pData[index]->handleI2C, 1);
        FE_SleepTime(10);
    }
    #endif
    /* Initial dibcom 7070 chip */
 //   test_dibcom_7070();
    error = dib_init();
    if( error != GD_OK )
        GM_Printf("dib_init error!\n");

    /* fill device data structure with call back functions */
    pData[index]->feCloseFct             = GD_FE_DIB7070X_Close;
    pData[index]->feSetSystemParamsFct   = GD_FE_DIB7070X_SetSystemParams;
    pData[index]->feResetFct             = GD_FE_DIB7070X_Reset;
    pData[index]->feTuneFct              = GD_FE_DIB7070X_Tune;
    pData[index]->feScanFct              = NULL;
    pData[index]->feSendDiseqcCommandFct = NULL;
    pData[index]->feGetStatusFct         = GD_FE_DIB7070X_GetStatus;
    pData[index]->feGetFECFct            = NULL;
    pData[index]->feGetAFCFct            = GD_FE_DIB7070X_GetAFC;
    pData[index]->feGetBERFct            = GD_FE_DIB7070X_GetBER;
    pData[index]->feGetSignalQualityFct  = GD_FE_DIB7070X_GetSignalQuality;
    pData[index]->feGetSignalStrengthFct = GD_FE_DIB7070X_GetSignalStrength;
    pData[index]->feGetTuneParamsFct     = GD_FE_DIB7070X_GetTuneParams;
    pData[index]->feSetAntennaPowerFct   = NULL;

    return GD_OK;
}
Ejemplo n.º 3
0
//*****************************************************************************
//** Main Function
//*****************************************************************************
void main(void)
{
	OS_STATUS OSStatus;
	
#if defined(GK6105S)
	*(volatile U32*)(0x81c2080) = 0x00000001;
#endif

    SystemInit();
    
    GM_Printf("\033[2J"); /* clear screen */
    GM_Printf("-------------------------------------------------\n");
    GM_Printf(" GK6105S KERNEL/UCOS Test Application\n");
    GM_Printf(" (C) Guoke Microelectronics 2012 - 2014\n");
    
#if defined(MY_UCOS)
    RTOS_Initialize(NULL);
    OSTaskCreate((void (*)(void *))KernelTest, 0, MainTaskStack, MainTaskPriority);
#else
    OSSysInit();
  	OSInit();
  	// OSStatus = OSAddTask((void (*)(void *))IdleTask, IdlePriority, IdleStack, IdleStackSize);
    OSStatus = OSAddTask((void (*)(void *))KernelTest, MainTaskPriority, MainTaskStack, MainTaskStackSize);
#endif
  	OSStart();
}
Ejemplo n.º 4
0
/*!
*******************************************************************************
**
** \brief  Set PWM mode
**
**         This function set pwm to normal speed mode or sync speed mode
**
**\param channel The PWM channel that specified.
**\param mode The PWM mode: 0 - Normal Speed Mode; 1 - Sync Speed Mode.
**
** \return
**         - #GD_OK if successful
******************************************************************************/
GERR GD_PWM_Set_Mode(U8 channel, U8 mode)
{
    if (channel >= GD_PWM_COUNT)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM channel has exceed the max channel number that can be set!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }
    if ((mode != 0) && (mode != 1))
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM mode invalid, it should be 0 or 1!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }
    if (GD_NORMAL_SPEED == mode)
    {
        GH_PWM_set_Mode_mode(channel, 0);
    }
    else
    {
        GH_PWM_set_Mode_mode(channel, 1);
    }
    return GD_OK;
}
Ejemplo n.º 5
0
void GM_SVL_FEConnect(U16 num)
{
    GERR error;

    if(num > MaxNumServices)
        return;

    error = GD_FE_Tune(FeHandle, &(FeTuneParams[SvcList[num].trpPos]));
    if (error != GD_OK)
        GM_Printf("\r\nERROR from GD_FE_Connect: %i\n", error);
    else
        GM_Printf("\r\nGD_FE_Connect\n");

}
Ejemplo n.º 6
0
GERR GD_FE_Altobeam_Tune(U8 index, GD_FE_TUNE_PARAMS_S* pTuneParams)
{
    U16 timeout = 100;

#ifdef GD_FE_TERRESTRIAL
    GD_FE_DtmbDemodInit(GD_FE_Altobeam_Init);
#endif
    SetDTMBTunerFrequencyKHz(pTuneParams->terr.frequency);
    //pTuneParams->sat.frequency = 546000;
    //下频点.
  
    while ( --timeout )
    {
        if ( ATBMLockedFlag()  == 0 )
        {
            Delayms(10);
            continue;
        }
        else
             return GD_OK;
    };
    
    if(timeout==0)
    {
        GM_Printf("Lock failed!\n");//
        return GD_ERR_FE_NOT_LOCKED;
    }
}
Ejemplo n.º 7
0
/*---------------------------------------------------------------------------*/
GERR GD_PWM_Set_Clock_Divider(U8 channel, U8 divider)
{
    if (channel >= GD_PWM_COUNT)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM channel has exceed the max channel number that can be set!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }
    if ((divider < 1) || (divider > 3))
    {
#ifdef DEBUG_PRINT
        GM_Printf("Invalid divider argument! Divider should between 1 to 3.\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }

    if (GH_PWM_get_Enable_enb(channel))
    {
        GH_PWM_set_Enable_enb(channel, 0);
    }
    
    if (divider == 1)
    {
        GH_PLL_set_SCALER_PWM(0x20);
#ifdef DEBUG_PRINT
        GM_Printf("Set PWM clock to 2.156MHz\n");
#endif
    }
    else if (divider == 2)
    {
        GH_PLL_set_SCALER_PWM(0x1AF4);
#ifdef DEBUG_PRINT
        GM_Printf("Set PWM clock to 10KHz\n");
#endif
    }
    else
    {
        GH_PLL_set_SCALER_PWM(0x1);
#ifdef DEBUG_PRINT
        GM_Printf("Set PWM clock to 34.5MHz\n");
#endif
    }

    return GD_OK;
}
Ejemplo n.º 8
0
void GM_SVL_Tune(U16 num)
{
    GERR  error;
    U16   tsdInput;

    if(num > MaxNumServices)
        return;
    //GD_FE_Disconnect()
    GD_AUD_Stop();
    GD_AUD_Close();
    GD_VID_Stop();
    GD_VID_Close();

    GM_Printf("\ntune to: %i  %s\n", num, SvcList[num].name);
    if(SvcList[num].trpPos != PreviousTrpPos)
    {
        error = GD_FE_Tune(FeHandle, &(FeTuneParams[SvcList[num].trpPos]));
        if (error != GD_OK)
            GM_Printf("\r\nERROR from GD_FE_Connect: %i\n", error);
        PreviousTrpPos = SvcList[num].trpPos;
    }
#ifdef AV_SEPRATE_FLAG
    tsdInput = GD_TSD_GetHardwareControlledBuffer(GD_TSD_VIDEO_PES);
#else
    tsdInput = GD_TSD_GetHardwareControlledBuffer();
#endif

    if(SvcList[num].vPid != 0)
    {
        GD_VID_Open(SvcList[num].vPid);
        GD_VID_Start();
        /* accelerate sync process so set PCR PID here */
        if(SvcList[num].vPid == SvcList[num].pcrPid || SvcList[num].pcrPid == 0)
            GD_TSD_SetPcrPid(tsdInput, SvcList[num].vPid);
    }
    if(SvcList[num].aPid != 0)
    {
        GD_AUD_Open(SvcList[num].aPid);
        GD_AUD_Start();
    }
    /* PCR should be last PID opened */
    if(SvcList[num].vPid == 0 || SvcList[num].vPid != SvcList[num].pcrPid) 
        GD_TSD_SetPcrPid(tsdInput, SvcList[num].pcrPid);
    CurrentService = num;
}
Ejemplo n.º 9
0
/******************************************************************************

Name:        US_Save

Description: Saves the user settings to flash.

Parameters:  none

Returns:     GD_OK
             GD_ERR_NOT_INITIALIZED

******************************************************************************/
GERR US_Save()
{
    U16 i;
#ifdef APPL_SERIALFLASH_ENABLE
    U8 buffer[sizeof(US_DATA_S)];
    U32 usWordLen;
#else
    U16 buffer[(sizeof(US_DATA_S)/2)+2];
#endif
    GD_HANDLE h;
    GERR ferr;

    if (initialised == GFALSE) return GD_ERR_NOT_INITIALIZED;


    GM_Printf("US: Writing user settings to flash memory...\n");
#ifdef APPL_SERIALFLASH_ENABLE
    for (i=0; i<sizeof(US_DATA_S); i++) buffer[i] = thisData.all[i];
    ferr = GD_SFLASH_Open(&h);
    if (ferr == GD_OK)
    {
    	usWordLen = (sizeof(US_DATA_S)+3)/4;
        ferr = GD_SFLASH_Write(h, US_FLASH_ADDRESS, (U32*)buffer, usWordLen);
        if (ferr == GD_OK) GM_Printf("US: Done.\n");
    }
    if (ferr != GD_OK) GM_Printf("US: Error!\n");

    GD_SFLASH_Close(&h);
#else

    buffer[0] = MAGIC_WORD_1;
    buffer[1] = MAGIC_WORD_2;
    for (i=0; i<sizeof(US_DATA_S)/2; i++) buffer[i+2] = thisData.all[i];
    ferr = GD_FL_Open(&h);
    if (ferr == GD_OK)
    {
        ferr = GD_FL_Program(h, US_FLASH_ADDRESS, buffer, sizeof(US_DATA_S)/2+2);
        if (ferr == GD_OK) GM_Printf("US: Done.\n");
    }
    if (ferr != GD_OK) GM_Printf("US: Error!\n");

    GD_FL_Close(&h);
#endif
    return ferr;
}
Ejemplo n.º 10
0
/*!
*******************************************************************************
**
** \brief  Enable or disable PWM output.
**
**         This function enbale or disable PWM output.
**
** \param channel The PWM channel that specified.
** \param enable Turn on PWM output if enable is 1, or turn off PWM output if enable is 0.
**
** \return
**         - #GD_OK if successful
******************************************************************************/
GERR  GD_PwmOnOff(U8 channel,U32 enable)
{
    if (enable == 0)
    {
        GH_PWM_set_Enable_enb(channel,0);
#ifdef DEBUG_PRINT
        GM_Printf("Set PWM%d OFF\n",channel);
#endif
    }
    else
    {
        GH_PWM_set_Enable_enb(channel,1);
#ifdef DEBUG_PRINT
        GM_Printf("Set PWM%d ON\n",channel);
#endif
    }
    return GD_OK;
}
Ejemplo n.º 11
0
void GM_SVL_PrintServiceList(void)
{
    U16 i=0;

    while(SvcList[i].name[0] != '\0')
    {
        GM_Printf("\n%i: %s", i, SvcList[i].name);
        i++;
    }
}
Ejemplo n.º 12
0
/*!
*******************************************************************************
**
** \brief  Set PWM logic high level, logic low level count.
**
**         This function can set PWM output frequency by specifying high level count and low level count,
** the PWM output frequency is caculated by output frequency=input frequency/(highLevelCnt+lowLevelCnt).
** Also, the PWM duty is highLevelCnt/(highLevelCnt+lowLevelCnt). The highLevelCnt/lowLevelCnt value should
** be 1~65536.
**
**\param channel The PWM channel that specified.
**\param highLevelCnt The PWM high level count.
**\param lowLevelCnt The PWM low level count.
**
** \return
**         - #GD_OK if successful
******************************************************************************/
GERR GD_PWM_Cycle(U8 channel, U32 highLevelCnt, U32 lowLevelCnt)
{
    GH_PWM_CONTROL_S pwm_control;
    GD_PWM_MODE_E mode;
    U32 pwmDiv = 0;
    U16 highLevelReg = 0;
    U16 lowLevelReg = 0;

    if (highLevelCnt < 1 || highLevelCnt > 65536 || lowLevelCnt < 1 || lowLevelCnt > 65536)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM highLevelCnt/lowLevelCnt is invalid!\n");
#endif   
        return GD_ERR_BAD_PARAMETER;
    }
    highLevelReg = (U16)(highLevelCnt - 1);
    lowLevelReg = (U16)(lowLevelCnt - 1);
    
    mode = (U8)GH_PWM_get_Mode_mode(channel);
    if(mode==GD_NORMAL_SPEED)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM work in normal mode\n");
#endif
        GH_PWM_set_Mode(channel,0);
        GH_PWM_set_Mode_divider(channel,pwmDiv);
        pwm_control.bitc.xon = highLevelReg - 1;
        pwm_control.bitc.xoff = lowLevelReg - 1;
        GH_PWM_set_Control(channel,pwm_control.all);
    }
    else if(mode==GD_SYNC_SPEED)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM work in sync mode\n");
#endif
        GH_PWM_set_Mode(channel,1);
        GH_PWM_set_Mode_divider(channel,pwmDiv);
        pwm_control.bitc.xon = highLevelReg - 1;
        pwm_control.bitc.xoff = lowLevelReg - 1;
        GH_PWM_set_Control(channel,pwm_control.all);
    }
    return GD_OK;
}
Ejemplo n.º 13
0
/******************************************************************************
**
** \brief  Opens the AVLlink1108 front-end device.
**
**         This function opens the front-end device and fills the device data
**         structure with the implemented callback functions.
**
** \param  index        Internal index of front-end.
** \param  pDeviceData  Pointer to device data structure.
**
** \return Possible return codes:
**         - #GD_OK
**         - #GD_ERR_BAD_PARAMETER
**         - #GD_ERR_FE_OPEN
**         - #GD_ERR_FE_OPEN_I2C
**
******************************************************************************/
GERR GD_FE_Altobeam_Open(U8 index, GD_FE_DEVICE_DATA_S* pDeviceData)
{
    
    GD_FE_Altobeam_Init();

    /*
    //Tune on specific frequency,SetDTMBTunerFrequencyKHz will call one of the following function.
    SetTunerTDAC2_Freq_KHz(666000);	  SetTunerSharp2093_Freq_KHz(666000);	  SetTunerTDAC_7_Freq_KHz(666000);
    SetTunerMaxlinear5007_KHz(666000);  SetTunerYTMB_04_KHz(666000);     
    //Maxlinear 601, 
    MXL601_PowerInit_DTMB();
    Set_MXL601_Tuner_Freq_KHz(666000);
    */
    #if 0
    SetDTMBTunerFrequencyKHz(666000);
    

    //CustomWaitMs(pNim->pBaseInterface, 1000);
    Delayms(1000);    
    //之后就可以读signal lock看信号有没有锁住了.
    if ( ATBMLockedFlag() == 1 )
    {
        //GM_Printf("Realtek lock successful!\n");//locked
    }
    else
    {
        GM_Printf("GD_FE_Altobeam_Open lock failed!\n");//unlocked
    }
    #endif
    /* fill device data structure with call back functions */
    pDeviceData->feCloseFct             = (GERR (*)(U8))GD_FE_Altobeam_Close;
    pDeviceData->feSetSystemParamsFct   = (GERR (*)(U8, GD_FE_SYSTEM_PARAMS_S*))GD_FE_Altobeam_SetSystemParams;
    pDeviceData->feResetFct             = (GERR (*)(U8))GD_FE_Altobeam_Reset;
    pDeviceData->feTuneFct              = (GERR (*)(U8, GD_FE_TUNE_PARAMS_S*))GD_FE_Altobeam_Tune;
    pDeviceData->feScanFct              = (GERR (*)(U8, GD_FE_SCAN_PARAMS_S*))GD_FE_Altobeam_Scan;
    //pDeviceData->feScanFct              = NULL;
    pDeviceData->feSendDiseqcCommandFct = (GERR (*)(U8, U8, U8*, U8*, U8*))GD_FE_Altobeam_SendDiseqcCommand;
    pDeviceData->feGetStatusFct         = (GERR (*)(U8, GD_FE_STATUS_E*))GD_FE_Altobeam_GetStatus;
    pDeviceData->feGetFECFct            = (GERR (*)(U8, GD_FE_FEC_E*))GD_FE_Altobeam_GetFEC;
    pDeviceData->feGetAFCFct            = NULL;
    pDeviceData->feGetBERFct            = (GERR (*)(U8, U32*))GD_FE_Altobeam_GetBER;
    pDeviceData->feGetSignalQualityFct  = (GERR (*)(U8, U16*))GD_FE_Altobeam_GetSignalQuality;
    pDeviceData->feGetSignalStrengthFct = (GERR (*)(U8, U16*))GD_FE_Altobeam_GetSignalStrength;
    pDeviceData->feGetTuneParamsFct     = NULL;
    pDeviceData->feSetAntennaPowerFct   = (GERR (*)(U8, GBOOL))GD_FE_Altobeam_SetAntennaPower;
    pDeviceData->feGetPnModeFct  =  (GERR (*)( int*))GD_FE_Altobeam_GetPnMode;
    pDeviceData->feGetQamModeFct=  (GERR (*)(int*))GD_FE_Altobeam_GetQamMode;
    pDeviceData->feGetCodeRateModeFct =  (GERR (*)(int*))GD_FE_Altobeam_GetCodeRateMode;

    /* store pointer to device data for later */
    //pData[index]      = pDeviceData;  
    return GD_OK;
}
Ejemplo n.º 14
0
/*!
*******************************************************************************
**
** \brief  Get PWM speed
**
**         This function get pwm divider in sync speed mode. 
**
**\param channel The PWM channel that specified.
**\param speed The pointer to get PWM divider in sync speed mode.
**
** \return
**         - #GD_OK if successful
******************************************************************************/
GERR GD_PWM_Get_Speed(U8 channel, U16 *speed)
{
    if (channel >= GD_PWM_COUNT)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM channel has exceed the max channel number that can be set!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }

    *speed = GH_PWM_get_Mode_divider(channel);
    
    return GD_OK;
}
Ejemplo n.º 15
0
/*!
*******************************************************************************
**
** \brief  Get PWM mode
**
**         This function get pwm mode. The mode is normal speed mode or sync speed mode.
**
**\param channel The PWM channel that specified.
**\param mode The pointer to get PWM mode: 0 - Normal Speed Mode; 1 - Sync Speed Mode.
**
** \return
**         - #GD_OK if successful
******************************************************************************/
GERR GD_PWM_Get_Mode(U8 channel, GD_PWM_MODE_E *mode)
{
    if (channel >= GD_PWM_COUNT)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM channel has exceed the max channel number that can be set!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }
    
    *mode = GH_PWM_get_Mode_mode(channel);
    
    return GD_OK;
}
Ejemplo n.º 16
0
AVL63X1_ErrorCode AVL63X1_IBSP_I2C_Read(  AVL_uint16 uiSlaveAddr,  AVL_puchar pucBuff, AVL_puint16 puiSize )
{
    AVL_uint32 ret=0;

  //  SYS_nvMutexWait();
    ret = GD_I2C_Read(&pi2cHandle,uiSlaveAddr<<1,0,0, pucBuff , *puiSize);
  //  SYS_nvMutexRelease();
    if ( ret != 0 )
        GM_Printf("AVL63X1_IBSP_I2C_Read failed:r=%d\n",ret);
    //else
    //    GM_Printf("GD_I2C_ReadRealtek successful:r=%d\n",r);
    
    return(ret);
    //return(AVL63X1_EC_OK);
}
Ejemplo n.º 17
0
void OSD_MENU_Show()
{
    RTOS_Size  bytes;
    U16        i;

    params.width  = menuInfo.width;

    if (menuInfo.height == 0) params.height = 52 + 
                              OSD_MENU_LINEHEIGHT * menuInfo.numberOfItems;
    else params.height = menuInfo.height;

    /* allocate OSD layer memory - memory must be freed on GD_OSD_CloseLayer() */
    bytes = sizeof(U32) * GD_OSD_CalculateMemorySize( GD_OSD_LAYER_MODE_8BIT, 
                                    params.width, params.height );
    params.startAddress = (U32)RTOS_SegmentMemoryAllocate( RTOS_osd_segment, 
                                    bytes, GTRUE );
    if(params.startAddress == NULL)
    {
        GM_Printf("[osd_menu] OSD_MENU_Show() out of memory!!!\n");
        RTOS_Halt();
    }
//    GM_Printf("[osd_menu] address:%lx  size:%i\n",params.startAddress, bytes);
    GD_OSD_OpenLayer(&params);
    while (GD_OSD_GetLayerOpenState(params.layer)==GFALSE); /* wait until opened */
    GD_OSD_HideLayer(params.layer);
    GD_OSD_MoveLayer(params.layer, menuInfo.x, menuInfo.y);

    OSD_DrawBackgroundWithFrame(&params);
    OSD_DrawFilledRectangle(&params, 4, 4, params.width-5, 41, OSD_COL_BACKGROUND_TITLE);
    OSD_DrawHorizontalLine(&params, 3, params.width-3, 42, OSD_COL_FRAME);
    OSD_DrawHorizontalLine(&params, 3, params.width-3, 43, OSD_COL_FRAME);
    OSD_DrawString(&params, 12, 4, OSD_COL_TEXT_TITLE, OSD_FONT24, menuInfo.title);

    for (i=0; i<menuInfo.numberOfItems; i++)
    {
        if (i==menuInfo.selectedItem) paintMenuItem(i, GTRUE);
        else paintMenuItem(i, GFALSE);
    }

    GD_OSD_ShowLayer(params.layer);
    isActive = GTRUE;
}
Ejemplo n.º 18
0
void OSD_NAVI_Show(U16 currentIndex)
{
    RTOS_Size bytes;
    navigatorIndex = currentIndex;

    /* allocate OSD layer memory - memory must be freed on GD_OSD_CloseLayer() */
    bytes = sizeof(U32) * GD_OSD_CalculateMemorySize( GD_OSD_LAYER_MODE_8BIT, 
                                    params.width, params.height );
    params.startAddress = (U32)RTOS_SegmentMemoryAllocate( RTOS_osd_segment, 
                                    bytes, GTRUE );
    if(params.startAddress == NULL)
    {
        GM_Printf("[osd_navi] OSD_NAVI_Show() out of memory!!!\n");
        RTOS_Halt();
    }
//    GM_Printf("[osd_navi] address:%lx  size:%i\n",params.startAddress, bytes);

    GD_OSD_OpenLayer(&params);
    while (GD_OSD_GetLayerOpenState(params.layer)==GFALSE); /* wait until opened */
    GD_OSD_HideLayer(params.layer);
    #ifdef NTSC
        GD_OSD_MoveLayer(params.layer, 50, 30); /* for NTSC */
    #else
        GD_OSD_MoveLayer(params.layer, 50, 40); /* for PAL */
    #endif

    OSD_DrawBackgroundWithFrame(&params);
    OSD_DrawFilledRectangle(&params, 4, 4, params.width-5, 41, OSD_COL_BACKGROUND_TITLE);
    OSD_DrawHorizontalLine(&params, 3, params.width-3, 42, OSD_COL_FRAME);
    OSD_DrawHorizontalLine(&params, 3, params.width-3, 43, OSD_COL_FRAME);
    OSD_DrawString(&params, 12, 4, OSD_COL_TEXT_TITLE, OSD_FONT24, "Navigator");

    paintList(navigatorIndex);

    GD_OSD_ShowLayer(params.layer);
    isActive = GTRUE;
}
Ejemplo n.º 19
0
/*!
*******************************************************************************
**
** \brief  Feeds data into VBV buffer.
**
**         \c GD_VID_OpenMemory() has to be called before.
**
** \param  dataP     Pointer to video data.
** \param  size      Number of 32 bit words to copy.
**
** \return Number of copied bytes.
**
** \sa     GD_VID_OpenMemory()    <br>
**         GD_VID_FlushData()     <br>
**         GD_VID_CloseMemory()   <br>
**
******************************************************************************/
U32 GD_VID_FeedData(U32 *dataP, U32 size)
{
#if defined(GK6105S)
    U16 i,k;
    U32 tt;
    U32 *p;
    U32 count;
    U32 indx = 0;
    U8  tsd;
    S16 pid;
    U32 time = 0;
    U32 vbvBufferSize = 0;
    U32 TsPacket = 0;
    U32 leftByte = 0;
    U8 MuxCfg = 0,writestep=0;
#else
    volatile U32* adt;
    U32 i;
    U8  tsd;
#endif

#if defined(GD_VID_GKFEEDDATA_DEBUG)
    U32 time_old = GD_TIMER_ReadTimerStamp();
    
    GM_Printf("GD_VID_FeedData started on %d\n", time_old);
#endif
    
    /* copy the Iframe header to IFrameHeader, it is used in GD_VID_FlushData*/
    IFrameHeader[0] = dataP[0];
    IFrameHeader[1] = dataP[1];
    
    if(VideoFromMemFlag == GFALSE)
        return 0;
    
#if defined(GK6105S)
    TsPacket = (size*4)/184;
        
    leftByte = (size*4)%184;        
    if(leftByte != 0)
    {
        TsPacket++;
    }
    /*add more ts packets to vbv*/
    TsPacket = TsPacket*4;
    
    // to be customized here
    pid = 0x123;
#ifdef AV_SEPRATE_FLAG
    tsd = GD_TSD_GetHardwareControlledBuffer(GD_TSD_VIDEO_PES);
#else
    tsd = GD_TSD_GetHardwareControlledBuffer();
#endif
        
    vbvBufferSize = GH_BM_get_BufferSize(tsd, GD_TSD_VIDEO_PES);
    GH_TSD_set_SyncDistance(0xFF);
    GH_TSD_set_SyncDistance(187);
    //GH_TSD_set_InputMode_TS1_AM_SYNC(1); 
    GH_VD_set_VideoControl_DEC( 0);    /* reset VD */
    GH_BM_set_BufferReadPointer(tsd, GD_TSD_VIDEO_PES,GH_BM_get_BufferWritePointer(tsd,GD_TSD_VIDEO_PES));
    //GH_BM_set_BufferWritePointer(tsd, GD_TSD_VIDEO_PES, vbvBufferSize-184);
    //GH_BM_set_BufferReadPointer(tsd, GD_TSD_VIDEO_PES, vbvBufferSize-184);
    GD_TSD_SetChannelPid(GD_TSD_VIDEO_PES, tsd, pid);

    if(tsd == GD_TSD_1)
    {
        MuxCfg = GH_TSD_getm_MuxConfig_TSD1_MUX_CFG();
        GH_TSD_set_InputMode_TS1_AM_SYNC(1); 
        GH_TSD_set_MuxConfig_TSD1_MUX_CFG(3);
    }
    else if(tsd == GD_TSD_2)
    {
        MuxCfg = GH_TSD_getm_MuxConfig_TSD2_MUX_CFG();
        GH_TSD_set_InputMode_TS2_AM_SYNC(1); 
        GH_TSD_set_MuxConfig_TSD2_MUX_CFG(3);
    }
//  #if defined (GK6106)
//      else if(tsd == GD_TSD_3)
//      {
//          MuxCfg = GH_TSD_getm_MuxConfig_TSD2_MUX_CFG();
//          GH_TSD34_set_InputMode_TS1_AM_SYNC(1); 
//          GH_TSD34_set_MuxConfig_TSD3_MUX_CFG(3);
//      }
//      else if(tsd == GD_TSD_4)
//      {
//          MuxCfg = GH_TSD_getm_MuxConfig_TSD2_MUX_CFG();
//          GH_TSD34_set_InputMode_TS2_AM_SYNC(1); 
//          GH_TSD34_set_MuxConfig_TSD4_MUX_CFG(3);
//      }
//  #endif
    GD_TSD_ControlChannel(GD_TSD_VIDEO_PES, tsd, GD_TSD_ENABLE);
        
    for(indx = 0; indx<1; indx++)
    {
        count = 0;
        p = (U32 *)dataP;
        for (k = 0; k < TsPacket;k++)
        {
            tt = 20000;
            while((GH_TSD_get_PacketControl(tsd) != 0) && ((--tt) > 0) );
            if(tt == 0)
                return 0;

            tt = 20000;
            while((GH_TSD_get_PacketStatus(tsd) != 0) && ((--tt) > 0) );
            if(tt == 0)
                return 0;           
            
            /* write the first ts packet at the end of the vbv buffer. */
            if(writestep == 0)
            {
                GH_TSD_set_Packet0(tsd, 0, (0x47<<24) | (k & 0xF)|(pid<<8)|(0x1<<4)|(0x0<<6));
                for(i=1;i<47;i++)
                {
                    GH_TSD_set_Packet0(tsd, i,*p++);
                    count++;
                    if (count%size==0 )
                    {
                        p = (U32 *)dataP;
                    }
                }
                GH_TSD_set_PacketControl(tsd, 4);
            }
            
            if(writestep == 1)
            {
                GH_TSD_set_Packet1(tsd, 0, (0x47<<24) | (k & 0xF)|(pid<<8)|(0x1<<4)|(0x0<<6));
                for(i=1;i<47;i++)
                {
                    GH_TSD_set_Packet1(tsd, i,*p++);
                    count++;
                    if (count%size==0 )
                    {
                        p = (U32 *)dataP;
                    }
                }
                GH_TSD_set_PacketControl(tsd, 0x50);
            }
            
            if(writestep == 2)
            {
                GH_TSD_set_Packet2(tsd, 0, (0x47<<24) | (k & 0xF)|(pid<<8)|(0x1<<4)|(0x0<<6));
                for(i=1;i<47;i++)
                {
                    GH_TSD_set_Packet2(tsd, i,*p++);
                    count++;
                    if (count%size==0 )
                    {
                        p = (U32 *)dataP;
                    }
                }
                GH_TSD_set_PacketControl(tsd, 0x600);
            }
            
            if(writestep == 3)
            {
                GH_TSD_set_Packet3(tsd, 0, (0x47<<24) | (k & 0xF)|(pid<<8)|(0x1<<4)|(0x0<<6));
                for(i=1;i<47;i++)
                {
                    GH_TSD_set_Packet3(tsd, i,*p++);
                    count++;
                    if (count%size==0 )
                    {
                        p = (U32 *)dataP;
                    }
                }
                GH_TSD_set_PacketControl(tsd, 0x7000);
            }
            
            writestep++;
            if(writestep > 3)
            {
                writestep = 0;
            }
        }
    }
    GD_TSD_ControlChannel(GD_TSD_VIDEO_PES, tsd, GD_TSD_DISABLE);
    if(tsd == GD_TSD_1)
    {
        GH_TSD_set_MuxConfig_TSD1_MUX_CFG(MuxCfg);
    }
    else if(tsd == GD_TSD_2)
    {
        GH_TSD_set_MuxConfig_TSD2_MUX_CFG(MuxCfg);
    }
//  #if defined (GK6106)
//      else if(tsd == GD_TSD_3)
//      {
//          GH_TSD34_set_MuxConfig_TSD3_MUX_CFG(MuxCfg);
//      }
//      else if(tsd == GD_TSD_4)
//      {
//          GH_TSD34_set_MuxConfig_TSD4_MUX_CFG(MuxCfg);
//      }
//  #endif
    NumStillDataBytes = count<<2;

#if defined(GD_VID_GKFEEDDATA_DEBUG)    
    time_old = GD_TIMER_ReadTimerStamp();
    GM_Printf("GD_VID_FeedData end on %d\n", time_old);
#endif
    
#else
    /* reset buffer pointer and stop decoder */
    GH_VD_set_VideoControl_DEC( 0);    /* reset VD */
#ifdef AV_SEPRATE_FLAG
    tsd = GD_TSD_GetHardwareControlledBuffer(GD_TSD_VIDEO_PES);
#else
    tsd = GD_TSD_GetHardwareControlledBuffer();
#endif
    GH_BM_set_BufferReadPointer( tsd, GD_TSD_VIDEO_PES, 0);
    GH_BM_set_BufferWritePointer(tsd, GD_TSD_VIDEO_PES, 0);

    /* copy data into VBV buffer */
    adt = GD_VID_GetBuffer();
    for (i=0; i < size; i++)
        adt[i]=dataP[i];
    /* A still image is only shown after a new image is going to be decoded. */
    /* Therefore we add a few bytes from the same image at the end. */
    for (i=0; i < 64; i++)
        adt[i+size]=adt[i];

    NumStillDataBytes = (size+64)<<2;
#endif

    return(NumStillDataBytes);
}
Ejemplo n.º 20
0
/*!
*******************************************************************************
**
** \brief  Set PWM Parameters
**
**         This function set PWM parameters that includes channel, range, frequency, and duty cycle.
**
** \param channel The PWM channel that specified.
** \param frequency The PWM output frequency that specified, the unit is Hz.
** \param range The PWM output adjustable range. For example, if range is 100, the PWM duty cycle
** can be set from 1% to 99%.
** \param duty The PWM duty cycle that specified.
** \return
**         - #GD_PWM_NO_ERR if successful
******************************************************************************/
GD_PWM_ERROR_CODE_E GD_PWM_Set_Param(U8 channel, U32 frequency, U32 range, U32 duty)
{
    U32 mode;
    U32 total;
    U32 pwmDiv;
    U32 clkPwm;
    U32 maxClkPwm;
    U32 minClkPwm;
    U32 apbClk;
    U64 multiple;
    U32 highLevelCnt;
    U32 lowLevelCnt;

    if (channel >= GD_PWM_COUNT)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM channel has exceed the max channel number that can be set!\n");
#endif
        return GD_PWM_ERR_NOT_SUPPORTED_CHANNEL;
    }
    if (frequency == 0)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM frequency can not be 0!\n");
#endif
        return GD_PWM_ERR_NOT_SUPPORTED_FREQUENCY;
    }
    if (range <= 1)
    {
#ifdef DEBUG_PRINT
        GM_Printf("The range is too small!\n");
#endif
        return GD_PWM_ERR_NOT_SUPPORTED_RANGE;
    }
    if ((duty == 0) || (duty >= range))
    {
#ifdef DEBUG_PRINT
        GM_Printf("The PWM duty can not be 0, or exceed the max range value!\n");
#endif
        if (duty == 0)
        {
            GD_GPIO_Write(Gpiohandle[channel], 0);
        }
        if (duty == range)
        {
            GD_GPIO_Write(Gpiohandle[channel], 1);
        }
        return GD_PWM_ERR_WRONG_DUTY_CONFIGURATION;
    }
    
    pwmDiv = GH_PLL_get_SCALER_PWM();
    apbClk = GD_GET_APB_ClkHz();
    switch (pwmDiv)
    {
        case 0x1: 
            clkPwm = apbClk;
            break;
        case 0x20:
            clkPwm = apbClk / 0x20;
            break;
        case 0x1AF4:
            clkPwm = apbClk / 0x1AF4;
            break;
        default:
            GH_PLL_set_SCALER_PWM(0x20);
            clkPwm = apbClk / 0x20;
            break;
    }
    maxClkPwm = clkPwm / 2;
    minClkPwm = clkPwm / (65536 * 2);
    if (frequency > maxClkPwm)
    {
        GH_PLL_set_SCALER_PWM(0x1);
        clkPwm = apbClk;
        maxClkPwm = clkPwm / 2;
        if (frequency > maxClkPwm)
        {
#ifdef DEBUG_PRINT
            GM_Printf("PWM frequency exceed the maximum pwm frequency that can be set!\n");
#endif
            return GD_PWM_ERR_NOT_SUPPORTED_FREQUENCY;
        }
    }
    if (frequency < minClkPwm)
    {
        GH_PLL_set_SCALER_PWM(0x1AF4);
        clkPwm = apbClk / 0x1AF4;
        minClkPwm = clkPwm / (65536 * 2);
        if (frequency < minClkPwm)
        {
#ifdef DEBUG_PRINT
            GM_Printf("PWM frequency exceed the minimum pwm frequency that can be set!\n");
#endif
            return GD_PWM_ERR_NOT_SUPPORTED_FREQUENCY;
        }
    }

    total = clkPwm / frequency;
    multiple = total * AMPLIFICATION / range;
    if ((multiple / AMPLIFICATION) < 1)
    {
#ifdef DEBUG_PRINT
        GM_Printf("Err: PWM range is too large, less than range %d is suggested!\n", total);
#endif
        //return GD_PWM_ERR_RANGE_EXCEED_LIMIT;
        range = total;
        duty = total / 2;
        highLevelCnt = duty;
    }
    else
    {
        highLevelCnt = duty * multiple / AMPLIFICATION;
    }
    lowLevelCnt = total - highLevelCnt;
    
    if (highLevelCnt > 0xFFFF)
    {
        duty = total / 2;
        highLevelCnt = duty;
        lowLevelCnt = total - highLevelCnt;
    }
    
    mode = GH_PWM_get_Mode_mode(channel);
    if(mode == GD_NORMAL_SPEED)
    {
        GH_PWM_set_Control_xon(channel, (highLevelCnt - 1));
        GH_PWM_set_Control_xoff(channel, (lowLevelCnt - 1));
    }
    else
    {
        GH_PWM_set_Control1_xon(channel, (highLevelCnt - 1));
        GH_PWM_set_Control1_xoff(channel, (lowLevelCnt - 1));
    }
    return GD_PWM_NO_ERR;
}
Ejemplo n.º 21
0
/*!
*******************************************************************************
**
** \brief  Get PWM Parameters
**
**         This function get PWM parameters that includes frequency, and duty cycle.
**
** \param channel The PWM channel that specified.
** \param frequency The current PWM output frequency, the unit is Hz.
** \param duty The current PWM duty cycle, the unit is %.
** \return
**         - #GD_OK if successful
**         - #GD_ERR_BAD_PARAMETER if input parameter is invalid
******************************************************************************/
GERR GD_PWM_Get_Param(U8 channel, U32 *frequency, U32 *duty)
{
    GD_PWM_MODE_E mode;
    U32 currentDuty = 0;
    U32 currentFrequency = 0;
    U32 total;
    U32 pwmDiv;
    U32 clkPwm;
    U32 apbClk;
    U16 highLevelCnt;
    U16 lowLevelCnt;

    if (channel >= GD_PWM_COUNT)
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM channel has exceed the max channel number that can be set!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }
    if ((frequency == NULL) || (duty == NULL))
    {
#ifdef DEBUG_PRINT
        GM_Printf("PWM frequency and duty are pointers to get PWM params, they can not be NULL!\n");
#endif
        return GD_ERR_BAD_PARAMETER;
    }

    pwmDiv = GH_PLL_get_SCALER_PWM();
    apbClk = GD_GET_APB_ClkHz();
    switch (pwmDiv)
    {
        case 0x1: 
            clkPwm = apbClk;
            break;
        case 0x20:
            clkPwm = apbClk / 0x20;
            break;
        case 0x1AF4:
            clkPwm = apbClk / 0x1AF4;
            break;
        default:
            GH_PLL_set_SCALER_PWM(0x20);
            clkPwm = apbClk / 0x20;
            break;
    }
    
    mode = GH_PWM_get_Mode_mode(channel);
    if(mode == GD_NORMAL_SPEED)
    {
        highLevelCnt = GH_PWM_get_Control_xon(channel) + 1;
        lowLevelCnt = GH_PWM_get_Control_xoff(channel) + 1;
    }
    else
    {
        highLevelCnt = GH_PWM_get_Control1_xon(channel) + 1;
        lowLevelCnt = GH_PWM_get_Control1_xoff(channel) + 1;
    }

    total = highLevelCnt + lowLevelCnt;
    currentFrequency = clkPwm / total;
    currentDuty = highLevelCnt * 100 / total;
    *frequency = currentFrequency;
    *duty = currentDuty;

    return GD_OK;
}
Ejemplo n.º 22
0
GERR GD_ETH_PHY_LAN8700_SetWorkMode(GD_HANDLE handle, GD_ETH_Work_ModeT workmode)
{
    /*Set MII mode: reg 18 bit 14---0:MII , 1:RMII*/
    U8      ii = 0;
    GBOOL   retval = GFALSE;
    U32     regval = (U32)0;
    GD_ETH_PHY_DEVICE_DATA_S* device = (GD_ETH_PHY_DEVICE_DATA_S*)handle;
    U8      addr = (U8)device->addr;
    // workmode.mode
    while(1)
    {
        regval = 0;
        retval = GD_ETH_ReadPhy(addr, PHY_addr(18,SCSR), &regval);
        if ( retval != GTRUE )
        {
#ifdef DEBUG_PRINT
            GM_Printf("%s:Failed to read PHY Reg_%d!\n",__FUNCTION__, PHY_addr(18,SCSR));
#endif
            return GD_ERR_ETH_PHY_RW;
        }

        if(workmode.mode == GD_ETH_PHY_IF_MODE_RMII)
        {
            /*RMII mode*/
            if((regval & PHY_mask(18,RPHY_MODE)) == PHY_val(18,RPHY_RMII))//MII mode: bit 10---0:MII , 1:RMII
            {
#ifdef DEBUG_PRINT
                GM_Printf("Rmii mode set OK!\n");
#endif
                break;
            }

            regval &= (~PHY_mask(18,RPHY_MODE));
            regval |= PHY_val(18,RPHY_RMII);
        }
        else if(workmode.mode == GD_ETH_PHY_IF_MODE_MII)
        {
            /*MII mode*/
            if((regval & PHY_mask(18,RPHY_MODE)) == PHY_val(18,RPHY_MII))//MII mode: bit 10---0:MII , 1:RMII
            {
#ifdef DEBUG_PRINT
                GM_Printf("mii mode set OK!\n");
#endif
                break;
            }

            regval &= (~PHY_mask(18,RPHY_MODE));
            regval |= PHY_val(18,RPHY_MII);
        }
        else
        {
            return GD_ERR_ETH_NOT_SUPPORTED;
        }

        retval = GD_ETH_WritePhy(addr, PHY_addr(18,SCSR), regval);
        if ( retval != GTRUE )
        {
#ifdef DEBUG_PRINT
            GM_Printf("%s:Failed to write PHY Reg_%d!\n",__FUNCTION__, PHY_addr(18,SCSR));
#endif
            return GD_ERR_ETH_PHY_RW;
        }

        ii++;
        if(ii >= 10)
        {
            //GM_Printf("%s mode set failure!\n", phy_str_for_if(pPhyDev->phyPort));
            return GD_ERR_ETH_PHY_OTHER;
        }
    }


    regval = (U32)0;
    /* loopback setting */
    // workmode.loopback
    regval &= (~PHY_mask(0,LOOPBACK));
    if (workmode.loopback == GD_ETH_LOOP_ON_PHY )
    {
        regval |= PHY_val(0,LOOPBACK);
    }

        /* auto nego */
    // workmode.bEnAutoNeg
    regval &= (~PHY_mask(0,AN_ENABLE));
    if (workmode.bEnAutoNeg == GTRUE)
    {
        regval |= PHY_val(0,AUTO_NEGO);
    }
    else
    {
        /* speed */
        // workmode.speed
        regval &= (~PHY_mask(0,SPEEDSELECT));
        if (workmode.speed == GD_ETH_SPEED_100M )   /* 100M */
        {
            regval |= PHY_val(0,100M);
        }
        else if (workmode.speed == GD_ETH_SPEED_10M )/* 10M */
        {
            regval |= PHY_val(0,10M);    //nothing need to do.
        }
        else
        {
            return GD_ERR_ETH_NOT_SUPPORTED;
        }

        /* duplex */
        // workmode.duplex
        regval &= (~PHY_mask(0,DUPLEX_MODE));
        if(workmode.duplex == GD_ETH_FULL_DUPLEX)   /* Full Duplex */
        {
            regval |= PHY_val(0,DUPLEX_FULL);
        }
        else if(workmode.duplex == GD_ETH_HALF_DUPLEX) /* half */
        {
            regval |= PHY_val(0,DUPLEX_HALF);    //nothing need to do.
        }
        else
        {
            return GD_ERR_ETH_NOT_SUPPORTED;
        }
    }
    /* write settings */
    retval = GD_ETH_WritePhy(addr, PHY_addr(0,BMCR), regval);
    if ( retval != GTRUE )
        return GD_ERR_ETH_PHY_RW;
    return GD_OK;
}
Ejemplo n.º 23
0
/******************************************************************************

Name:        GM_SVL_Menu

Description: This function is the main menu loop. It waits for IR key input
             before it performs an action.

Parameters:  need handle for IR and FE

Returns:     None

******************************************************************************/
void GM_SVL_InputHandler( U8 keyValue, U8 deviceID, U8 repeatFlag)
{
    U8  volLeft, volRight;
    GD_VO_PICTURE_WINDOW_S  screen;
    U16  i,j, k;

    switch(keyValue)
    {
        case 0x14 : /* 'STANDBY' */     GM_Printf("Key: STANDBY\n"); break;
        case 0x03 : /* 'EXIT' */        GM_Printf("Key: EXIT\n"); break;
        case 0x0f : /* 'TEXT' */        GM_Printf("Key: TEXT\n"); break;
        case 0x0a : /* 'APPL' */        GM_Printf("Key: APPL\n"); break;
        case 0x43 : /* 'MENU' */        GM_Printf("Key: MENU\n"); break;
        case 0x01 : /* 'HIDE' */        GM_Printf("Key: HIDE\n"); break;
        case 0x06 : /* 'ARROW UP' */    GM_Printf("Key: ARROW UP\n"); break;
        case 0x44 : /* 'ARROW DOWN' */  GM_Printf("Key: ARROW DOWN\n"); break;
        case 0x47 : /* 'ARROW LEFT' */  GM_Printf("Key: ARROW LEFT\n"); break;
        case 0x40 : /* 'ARROW RIGHT' */ GM_Printf("Key: ARROW RIGHT\n"); break;
        case 0x07 : /* 'OK' */          GM_Printf("Key: OK\n"); break;
        case 0x53 : /* 'VCR' */         GM_Printf("Key: VCR\n"); break;
        case 0x42 : /* 'RED' */         GM_Printf("Key: RED\n"); break;
        case 0x0e : /* 'GREEN' */       GM_Printf("Key: GREEN\n"); break;
        case 0x1a : /* 'YELLOW' */      GM_Printf("Key: YELLOW\n"); break;
        case 0x02 : /* 'BLUE' */        GM_Printf("Key: BLUE\n"); break;

        case 0x1d : /* '1' */ SVL_NumericKeyHandler(1); break;
        case 0x1f : /* '2' */ SVL_NumericKeyHandler(2); break;
        case 0x57 : /* '3' */ SVL_NumericKeyHandler(3); break;
        case 0x19 : /* '4' */ SVL_NumericKeyHandler(4); break;
        case 0x1b : /* '5' */ SVL_NumericKeyHandler(5); break;
        case 0x41 : /* '6' */ SVL_NumericKeyHandler(6); break;
        case 0x15 : /* '7' */ SVL_NumericKeyHandler(7); break;
        case 0x17 : /* '8' */ SVL_NumericKeyHandler(8); break;
        case 0x46 : /* '9' */ SVL_NumericKeyHandler(9); break;
        case 0x52 : /* '0' */ SVL_NumericKeyHandler(0); break;
        case 0x0d : /* 'P+' */
            GM_SVL_ProgramUpDown( 1 );
            break;
        case 0x11 : /* 'P-' */
            GM_SVL_ProgramUpDown(-1 );
            break;
        case 0x09 : /* 'TV' */
            break;
        case 0x10 : /* 'MUTE' */
            if( MuteFlag == GTRUE)
            {
                GM_Printf("Key: MUTE -> un-mute output\n");
                GD_AO_UnMute();
                MuteFlag = GFALSE;
            }
            else
            {
                GM_Printf("Key: MUTE -> mute output\n");
                GD_AO_Mute();
                MuteFlag = GTRUE;
            }
            break;
        case 0x00 : /* 'FORWARD' */
            GM_Printf("Key: FORWARD -> up-scaling\n");
            GD_VO_GetOutputPicture(0,&screen);
            if( screen.hsize < 2*720-44 )
                screen.hsize += 44;
            if( screen.vsize < 2*576-36 )
                screen.vsize += 36;
            if( screen.vsize > 864 )
            {
                screen.vsize = 1152;
                screen.hsize = 1440;
            }
            else if( screen.vsize > 576 )
            {
                screen.vsize = 864;
                screen.hsize = 1080;
            }
            GD_VO_SetOutputPicture(0,&screen);
            break;
        case 0x55 : /* 'REWIND' */
            GM_Printf("Key: REWIND -> down-scaling\n");
            GD_VO_GetOutputPicture(0,&screen);
            if( screen.hsize > 140+44 )
                screen.hsize -= 44;
            if( screen.vsize > 100+36 )
                screen.vsize -= 36;
            if( screen.vsize > 864 )
            {
                screen.vsize = 864;
                screen.hsize = 1080;
            }
            else if( screen.vsize > 576 )
            {
                screen.vsize = 576;
                screen.hsize = 720;
            }
            GD_VO_SetOutputPicture(0,&screen);
            break;
        case 0x56 : /* 'PLAY' */
            GM_Printf("Key: PLAY\n");
            GD_VO_GetOutputPicture(0,&screen);
            i=screen.hsize;
            j=i;
            while(i>100)
            {
                i-=2;
                screen.hsize = i;
                GD_VO_SetOutputPicture(0,&screen);
                for(k=0;k<47000;k++);
            }
            while(i<j)
            {
                i+=2;
                screen.hsize = i;
                for(k=0;k<47000;k++);
                GD_VO_SetOutputPicture(0,&screen);
            }
            break;
        case 0x1e : /* 'NAVI' */
            GM_Printf("Key: NAVI -> print service list\n");
            GM_SVL_PrintServiceList();
            break;
        case 0x5f : /* 'VOL UP' */
            volLeft = 0; volRight = 0;
            GD_AO_GetVolume(&volLeft, &volRight);

            if((volLeft+8 >= GD_AO_MAX_VOL) || (volRight+8 >= GD_AO_MAX_VOL))
            {
                volLeft  = GD_AO_MAX_VOL;
                volRight = GD_AO_MAX_VOL;
            }
            else
            {
                volLeft  += 8;
                volRight += 8;
            }
            GD_AO_SetVolume(volLeft, volRight);
            GM_Printf("Key: VOL UP -> vol=%i\n", volRight);
            break;
        case 0x18 : /* 'VOL DOWN' */
            volLeft = 0; volRight = 0;
            GD_AO_GetVolume(&volLeft, &volRight);
            if((volLeft-8 <= 0) || (volRight-8 <= 0))
            {
                volLeft  = 0;
                volRight = 0;
            }
            else
            {
                volLeft  -= 8;
                volRight -= 8;
            }
            GD_AO_SetVolume(volLeft, volRight);
            GM_Printf("Key: VOL DOWN -> vol=%i\n", volRight);
            break;

        default :
            GM_Printf("\nIR ??? -> DeviceID:0x%hx value:0x%hx repeat:%i\n",
                            deviceID, keyValue, repeatFlag);
            break;
    }
}
Ejemplo n.º 24
0
/******************************************************************************
**
** \brief  Tunes the front-end.
**
** \param  index        Internal index of front-end.
** \param  pTuneParams  Pointer to tuning parameters.
**
** \return Possible return codes:
**         - #GD_OK
**         - #GD_ERR_BAD_PARAMETER
**         - #GD_ERR_FE_BUSY
**         - #GD_ERR_FE_I2C
**         - #GD_ERR_FE_TUNE
**
******************************************************************************/
GERR GD_FE_MB86667_Tune(U8 index, GD_FE_TUNE_PARAMS_S* pTuneParams)
{
    GD_FE_IQ_E iq;
    GERR       error = GD_OK;
    /* MB86667 types: */
    MB86667_TRANSPONDER_T tpt;
    MB86667_SATELLITE_T   st;

    if (index >= GD_FE_MAX_NUM) return GD_ERR_BAD_PARAMETER;

    tpt.frequency  = (U32)(pTuneParams->sat.frequency);
    /* use the direct symbol rate value when an external 4MHz crystal is used */
    tpt.symbolrate = (U16)(pTuneParams->sat.symbolRate);

    /* fec: */
    if (pData[index]->pSystemParams->sat.autoFEC == GTRUE) tpt.fec = FEC_AUTO;
    else
    {
        switch (pTuneParams->sat.fec)
        {
            case GD_FE_FEC_1_2: tpt.fec = FEC_1_2;  break;
            case GD_FE_FEC_2_3: tpt.fec = FEC_2_3;  break;
            case GD_FE_FEC_3_4: tpt.fec = FEC_3_4;  break;
            case GD_FE_FEC_5_6: tpt.fec = FEC_5_6;  break;
            case GD_FE_FEC_7_8: tpt.fec = FEC_7_8;  break;
            default:            tpt.fec = FEC_AUTO; break;
        }
    }

    tpt.params = 0;
    /* polarization: */
    /* ignore circular types because they are not supported */
    if (pTuneParams->sat.pol == GD_FE_POL_VER) tpt.params |= POL_VER;
    else tpt.params |= POL_HOR;
    /* IQ: */
    iq = pData[index]->pSystemParams->sat.defaultIQ; /* first use global */
    if (iq == GD_FE_IQ_NONE) iq = pTuneParams->sat.iq;
    switch (iq)
    {
        case GD_FE_IQ_NONE:     tpt.params |= MB86667_AUTO_IQ; break;
        case GD_FE_IQ_NORMAL:                              break;
        case GD_FE_IQ_INVERTED: tpt.params |= MB86667_IQ_INV;  break;
        case GD_FE_IQ_AUTO:     tpt.params |= MB86667_AUTO_IQ; break;
        default: break;
    }

    st.LNBlowfreq  = (U32)(pData[index]->pSystemParams->sat.lowFrequency);
    st.LNBhighfreq = (U32)(pData[index]->pSystemParams->sat.highFrequency);
    st.satID       = (U16)(pTuneParams->sat.satID);

    if (st.LNBlowfreq == 0)  st.LNBlowfreq = st.LNBhighfreq;
    if (st.LNBhighfreq == 0) st.LNBhighfreq = st.LNBlowfreq;
    //todo: frequency for SMATV

    MB86667_SetContext(index,
                   pData[index]->ghwIndex,
                   pData[index]->handleI2C,
                   pData[index]->i2cAddrDemod,
                   pData[index]->i2cAddrTuner,
                   rf_ini_fct[index],
                   rf_set_fct[index]);
    error = MB86667_Tune(&tpt, &st, GFALSE);

    #ifdef GD_FE_MB86667_DEBUG01
        GM_Printf("MB86667_Tune(%i) = 0x%X\n",index,(U32)error);
    #endif

    MB86667_SaveContext(index);

    return error;
}
Ejemplo n.º 25
0
unsigned short runICAM2XEmmTests()
{
	U32 value = 0;
	U8 exit = 0;

	do
	{
		DebugPrint("EMM PACKET RECEPTION TEST\n");
		
		GM_Printf("\n\nEMM Tests\n");
		GM_Printf("Select tests to run:\n");
		GM_Printf(" Tests 201-214 \n"); 
		GM_Printf(" Tests 221 \n"); 
		GM_Printf(" Tests 223-241 \n"); 
		GM_Printf(" Tests 251-263 \n");
		GM_Printf("Enter selection.Enter 0 to exit\n");
		
		GM_ScanNum("%d\n", &value);

		GM_Printf("\n\n");
		
		switch(value) {
			case 0:
				exit = 1;
				break;		
			case 1:
				//DoCATest1();
				// automatic tests
				DoEMM1();
				break;
			case 2:
				//DoCATest2();
				break;
			case 201:
				DoCAEmmTest201();
				break;
			case 202:
				DoCAEmmTest202();
				break;
			case 203:
				DoCAEmmTest203();
				break;
			case 204:
				DoCAEmmTest204();
				break;
			case 205:
				DoCAEmmTest205();
				break;
			case 206:
				DoCAEmmTest206();
				break;
			case 207:
				DoCAEmmTest207();
				break;
			case 208:
				DoCAEmmTest208();
				break;
			case 209:
				DoCAEmmTest209();
				break;
			case 210:
				DoCAEmmTest210();
				break;
			case 211:
				DoCAEmmTest211();
				break;
			case 212:
				DoCAEmmTest212();
				break;
			case 213:
				DoCAEmmTest213();
				break;
			case 214:
				DoCAEmmTest214();
				break;
			case 221:
				DoCAEmmTest221();
				break;
			case 223:
				DoCAEmmTest223();
				break;
			case 224:
				DoCAEmmTest224();
				break;
			case 225:
				DoCAEmmTest225();
				break;
			case 226:
				DoCAEmmTest226();
				break;
			case 227:
				DoCAEmmTest227();
				break;
			case 228:
				DoCAEmmTest228();
				break;
			case 229:
				DoCAEmmTest229();
				break;
			case 230:
				DoCAEmmTest230();
				break;
			case 231:
				DoCAEmmTest231();
				break;
			case 232:
				DoCAEmmTest232();
				break;
			case 233:
				DoCAEmmTest233();
				break;
			case 234:
				DoCAEmmTest234();
				break;
			case 235:
				DoCAEmmTest235();
				break;
			case 236:
				DoCAEmmTest236();
				break;
			case 237:
				DoCAEmmTest237();
				break;
			case 238:
				DoCAEmmTest238();
				break;
			case 239:
				DoCAEmmTest239();
				break;
			case 240:
				DoCAEmmTest240();
				break;
			case 241:
				DoCAEmmTest241();
				break;
			case 251:
				DoCAEmmTest251();
				break;
			case 252:
				DoCAEmmTest252();
				break;
			case 253:
				DoCAEmmTest253();
				break;
			case 254:
				DoCAEmmTest254();
				break;
			case 255:
				DoCAEmmTest255();
				break;
			case 256:
				DoCAEmmTest256();
				break;
			case 257:
				DoCAEmmTest257();
				break;
			case 258:
				DoCAEmmTest258();
				break;
			case 259:
				DoCAEmmTest259();
				break;
			case 260:
				DoCAEmmTest260();
				break;
			case 261:
				DoCAEmmTest261();
				break;
			case 262:
				DoCAEmmTest262();
				break;
			case 263:
				DoCAEmmTest263();
				break;
			default:
				GM_Printf("Unknow command!\n");
		}
	}while(exit == 0);

	return 0;
}
Ejemplo n.º 26
0
unsigned short runICAM2xEcmTests()
{
	U32 value = 0;
	U8 exit = 0;
    extern void Do_ResetEcmCount(void);
	do
	{
        Do_ResetEcmCount();
		DebugPrint("ECM PACKET RECEPTION TEST\n");
		
		GM_Printf("\n\nECM Tests\n");
		GM_Printf("Select tests to run:\n");
		GM_Printf(" Tests 401-405 \n"); 
		GM_Printf(" Tests 414-415 \n"); 
		GM_Printf(" Tests 420-422 \n"); 
		GM_Printf(" Tests 424-426 \n");
		GM_Printf(" Tests 432 \n");
		GM_Printf(" Tests 460 \n");
		GM_Printf(" Tests 485 \n");
		GM_Printf("Enter selection. Enter 0 to exit\n");

		GM_ScanNum("%d\n", &value);

		GM_Printf("\n\n");

		switch(value) {
			case 0:
				exit = 1;
				break;
			case 1:
			    DoECM1();
				break;
			case 401:
				DoCAEcmTest401();
				break;
	        case 402:
	            DoCAEcmTest402();
	            break;
	        case 403:
	            DoCAEcmTest403();
	            break;
			case 404:
				DoCAEcmTest404();
				break;
			case 405:
				DoCAEcmTest405();
				break;
			 case 414:
				DoCAEcmTest414();
				break;
			 case 415:
				DoCAEcmTest415();
				break;
			 case 420:
				DoCAEcmTest420();
				break;
			 case 421:
				DoCAEcmTest421();
				break;
			 case 422:
				DoCAEcmTest422();
				break;
			 case 424:
				DoCAEcmTest424();
				break;
			 case 425:
				DoCAEcmTest425();
				break;
			 case 426:
				DoCAEcmTest426();
				break;
			 case 432:
				DoCAEcmTest432();
				break;
	//		 case 451:
	//			DoCAEcmTest451();
	//			break;
	//		 case 454:
	//			DoCAEcmTest454();
	//			break;
			 case 460:
				DoCAEcmTest460();
				break;
			case 333:
				DoCAEcmTest333();
				break;
	//		 case 483:
	//			DoCAEcmTest483();
	//			break;
	//		 case 484:
	//			DoCAEcmTest484();
	//			break;
			 case 485:
				DoCAEcmTest485();
				break;
	//		 case 486:
	//			DoCAEcmTest486();
	//			break;
		}
	}while(exit == 0);
	
	return 0;
}