⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d0399e.c

📁 st7710的tuner标准驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
    Demod->demod_Tracking         = demod_d0399_Tracking;        
    Demod->demod_ScanFrequency    = demod_d0399_ScanFrequency;
    /*Added for DiSEqC Support*/
	Demod->demod_DiSEqC	  = demod_d0399_DiSEqC;
	Demod->demod_GetConfigDiSEqC   = demod_d0399_DiSEqCGetConfig;  
	Demod->demod_SetDiSEqCBurstOFF   = demod_d0399_DiSEqCBurstOFF;

    Demod->demod_ioaccess = demod_d0399_ioaccess;
    Demod->demod_ioctl    = demod_d0399_ioctl;
    Demod->demod_tonedetection = demod_d0399_tonedetection;

    InstanceChainTop = NULL;
    
#if defined(ST_OS21) || defined(ST_OSLINUX) 
   Lock_InitTermOpenClose= semaphore_create_fifo(1);
#else
    semaphore_init_fifo(&Lock_InitTermOpenClose, 1);
#endif

    Installed = TRUE;

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
    STTBX_Print(("ok\n"));
#endif

    return(Error);
}



/* ----------------------------------------------------------------------------
Name: STTUNER_DRV_DEMOD_STV0399_UnInstall()

Description:
    install a satellite device driver into the demod database.
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t STTUNER_DRV_DEMOD_STV0399_UnInstall(STTUNER_demod_dbase_t *Demod)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
   const char *identity = "STTUNER d0399.c STTUNER_DRV_DEMOD_STV0399_UnInstall()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;

    if(Installed == FALSE)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail driver not installed\n", identity));
#endif
        return(STTUNER_ERROR_INITSTATE);
    }
   
    if(Demod->ID != STTUNER_DEMOD_STV0399)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail incorrect driver type\n", identity));
#endif
        return(STTUNER_ERROR_ID);
    }

    /* has all memory been freed, by Term() */
    if(InstanceChainTop != NULL)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail at least one instance not terminated\n", identity));
#endif
        return(ST_ERROR_OPEN_HANDLE);
    }


#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
    STTBX_Print(("%s uninstalling sat:demod:STV0399...", identity));
#endif

    /* mark ID in database */
    Demod->ID = STTUNER_NO_DRIVER;

    /* unmap API */
    Demod->demod_Init = NULL;
    Demod->demod_Term = NULL;

    Demod->demod_Open  = NULL;
    Demod->demod_Close = NULL;

    Demod->demod_IsAnalogCarrier  = NULL; 
    Demod->demod_GetSignalQuality = NULL;
    Demod->demod_GetModulation    = NULL;   
    Demod->demod_SetModulation    = NULL;   
    Demod->demod_GetAGC           = NULL;          
    Demod->demod_GetFECRates      = NULL;
    Demod->demod_GetIQMode        = NULL; /*added for GNBvd26107->I2C failure due to direct access to demod device at API level*/
    Demod->demod_IsLocked         = NULL;       
    Demod->demod_SetFECRates      = NULL;     
    Demod->demod_Tracking         = NULL;        
    Demod->demod_ScanFrequency    = NULL;
    
	Demod->demod_DiSEqC	          = NULL;
	Demod->demod_GetConfigDiSEqC  = NULL;  
	Demod->demod_SetDiSEqCBurstOFF= NULL;

    Demod->demod_ioaccess = NULL;
    Demod->demod_ioctl    = NULL;
    Demod->demod_tonedetection = NULL;

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("<"));
#endif
#if defined(ST_OS21) || defined(ST_OSLINUX)   
	semaphore_delete(Lock_InitTermOpenClose);    
#else	
        semaphore_delete(&Lock_InitTermOpenClose);
#endif

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print((">"));
#endif

    InstanceChainTop = (D0399_InstanceData_t *)0x7ffffffe;
    Installed        = FALSE;

#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("ok\n"));
#endif

    return(Error);
}

#endif

/* ------------------------------------------------------------------------- */
/* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ API /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
Name: demod_d0399_Init()

Description:
    
Parameters:

Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0399_Init(ST_DeviceName_t *DeviceName, DEMOD_InitParams_t *InitParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
    const char *identity = "STTUNER d0399.c demod_d0399_Init()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
#ifndef STTUNER_MINIDRIVER
    D0399_InstanceData_t *InstanceNew, *Instance;

    if(Installed == FALSE)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail driver not installed\n", identity));
#endif
        return(STTUNER_ERROR_INITSTATE);
    }

    /* now safe to lock semaphore */
    SEM_LOCK(Lock_InitTermOpenClose);

    /* ---------- check params ---------- */
    Error = STTUNER_Util_CheckPtrNull(InitParams->MemoryPartition);
    if( Error != ST_NO_ERROR)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail MemoryPartition not valid\n", identity));
#endif
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(Error);
    }

    Error = STTUNER_Util_CheckPtrNull(DeviceName);
    if( Error != ST_NO_ERROR)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail DeviceName not valid\n", identity));
#endif
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(Error);
    }

    InstanceNew = memory_allocate_clear(InitParams->MemoryPartition, 1, sizeof( D0399_InstanceData_t ));
    if (InstanceNew == NULL)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail memory allocation InstanceNew\n", identity));
#endif    
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(ST_ERROR_NO_MEMORY);           
    }

    /* slot into chain */
    if (InstanceChainTop == NULL)
    {
        InstanceNew->InstanceChainPrev = NULL; /* no previous instance */
        InstanceChainTop = InstanceNew;
    }
    else    /* tag onto last data block in chain */
    {
        Instance = InstanceChainTop;

        while(Instance->InstanceChainNext != NULL)
        {
            Instance = Instance->InstanceChainNext;   /* next block */
        }
        Instance->InstanceChainNext     = (void *)InstanceNew;
        InstanceNew->InstanceChainPrev  = (void *)Instance;
    }

    InstanceNew->DeviceName          = DeviceName;
    InstanceNew->TopLevelHandle      = STTUNER_MAX_HANDLES;
    InstanceNew->IOHandle            = InitParams->IOHandle;
    InstanceNew->MemoryPartition     = InitParams->MemoryPartition;
    InstanceNew->InstanceChainNext   = NULL; /* always last in the chain */
    InstanceNew->ExternalClock       = InitParams->ExternalClock;  
    InstanceNew->TSOutputMode        = InitParams->TSOutputMode;
    InstanceNew->SerialClockSource   = InitParams->SerialClockSource;
    InstanceNew->ClockPolarity       = InitParams->ClockPolarity;
    InstanceNew->DataClockAtParityBytes = InitParams->DataClockAtParityBytes;
    InstanceNew->TSDataOutputControl = InitParams->TSDataOutputControl;
    InstanceNew->BlockSyncMode       = InitParams->BlockSyncMode;
    InstanceNew->DataFIFOMode        = InitParams->DataFIFOMode;
    InstanceNew->OutputFIFOConfig    = InitParams->OutputFIFOConfig;
    InstanceNew->SerialDataMode      = InitParams->SerialDataMode;
       
    InstanceNew->FECMode             = InitParams->FECMode;
    InstanceNew->FE_399_Modulation   = FE_MOD_QPSK; /* default to QPSK modulation */

    /* parameters to pass to the CHIP API (I2C name, address etc.) */
    InstanceNew->DeviceMap.MemoryPartition = InitParams->MemoryPartition;
    InstanceNew->DeviceMap.Mode        = IOREG_MODE_SUBADR_8; /* normal <addr><reg No.><data> access */

    InstanceNew->DeviceMap.Registers= STV399_NBREGS; /* number of registers */
    /********Added for DiSEqC***************************/
    InstanceNew->DiSEqCConfig.Command   = STTUNER_DiSEqC_COMMAND;
    InstanceNew->DiSEqCConfig.ToneState = STTUNER_DiSEqC_TONE_CONTINUOUS_OFF;
	/**************************************************/
   
     
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
    STTBX_Print(("%s allocated & initalized block named '%s' at 0x%08x (%d bytes)\n", identity, InstanceNew->DeviceName, (U32)InstanceNew, sizeof( D0399_InstanceData_t ) ));
#endif
    SEM_UNLOCK(Lock_InitTermOpenClose);
    
  #endif
/************************************MINIDRIVER******************************
******************************************************************************
********************************************************************************/
#ifdef STTUNER_MINIDRIVER
        #ifdef ST_OS21    
	    Lock_InitTermOpenClose = semaphore_create_fifo(1);
	#else
	    semaphore_init_fifo(&Lock_InitTermOpenClose, 1);
	#endif   
    /* now safe to lock semaphore */
    SEM_LOCK(Lock_InitTermOpenClose);

    DEMODInstance = memory_allocate_clear(InitParams->MemoryPartition, 1, sizeof( D0399_InstanceData_t ));
    if (DEMODInstance == NULL)
    {
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(ST_ERROR_NO_MEMORY);           
    }
    DEMODInstance->DeviceName          = DeviceName;
    DEMODInstance->TopLevelHandle      = STTUNER_MAX_HANDLES;
    DEMODInstance->MemoryPartition     = InitParams->MemoryPartition;
    
    DEMODInstance->ExternalClock       = InitParams->ExternalClock;  
    DEMODInstance->TSOutputMode        = InitParams->TSOutputMode;
    DEMODInstance->SerialDataMode      = InitParams->SerialDataMode;
    DEMODInstance->SerialClockSource   = InitParams->SerialClockSource;
    /* add block sync bit control for bug GNBvd27452*/
    #ifdef STTUNER_BLOCK_SYNC_MODE_SELECT
    DEMODInstance->BlockSyncMode       = InitParams->BlockSyncMode;
    DEMODInstance->DataFIFOMode        = InitParams->DataFIFOMode;
    DEMODInstance->OutputFIFOConfig    = InitParams->OutputFIFOConfig;
    #endif
    DEMODInstance->FECMode             = InitParams->FECMode;
    DEMODInstance->FE_399_Modulation   = FE_MOD_QPSK; /* default to QPSK modulation */
    /********Added for DiSEqC***************************/
    DEMODInstance->DiSEqCConfig.Command   = STTUNER_DiSEqC_COMMAND;
    DEMODInstance->DiSEqCConfig.ToneState = STTUNER_DiSEqC_TONE_CONTINUOUS_OFF;
	/**************************************************/
    
	#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
	    STTBX_Print(("%s allocated & initalized block named '%s' at 0x%08x (%d bytes)\n", identity, InstanceNew->DeviceName, (U32)InstanceNew, sizeof( D0399_InstanceData_t ) ));
	#endif
    SEM_UNLOCK(Lock_InitTermOpenClose);
    
  #endif
  
    return(Error);
}   



/* ----------------------------------------------------------------------------
Name: demod_d0399_Term()

Description:
    
Parameters:
    
Return Value:
---------------------------------------------------------------------------- */
ST_ErrorCode_t demod_d0399_Term(ST_DeviceName_t *DeviceName, DEMOD_TermParams_t *TermParams)
{
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
   const char *identity = "STTUNER d0399.c demod_d0399_Term()";
#endif
    ST_ErrorCode_t Error = ST_NO_ERROR;
    
#ifndef STTUNER_MINIDRIVER
    D0399_InstanceData_t *Instance, *InstancePrev, *InstanceNext;

    if(Installed == FALSE)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail driver not installed\n", identity));
#endif
        return(STTUNER_ERROR_INITSTATE);
    }

    /* now safe to lock semaphore */
    SEM_LOCK(Lock_InitTermOpenClose);

    /* ---------- check params ---------- */
    Error = STTUNER_Util_CheckPtrNull(TermParams);
    if( Error != ST_NO_ERROR)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail TermParams not valid\n", identity));
#endif
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(Error);
    }

    /* ---------- check that at least one init has taken place ---------- */
    if(InstanceChainTop == NULL)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("%s fail nothing initalized\n", identity));
#endif
        SEM_UNLOCK(Lock_InitTermOpenClose);
        return(STTUNER_ERROR_INITSTATE);
    }


    /* reap next matching DeviceName */
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
    STTBX_Print(("%s reap next matching DeviceName[", identity));
#endif

    Instance = InstanceChainTop;
    while(1)
    {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
        STTBX_Print(("(%s)", Instance->DeviceName));
#endif
        if ( strcmp( (char *)Instance->DeviceName, (char *)DeviceName) == 0)
        {
#ifdef STTUNER_DEBUG_MODULE_SATDRV_D0399
            STTBX_Print(("<-- ]\n"));
#endif
            /* found so now xlink prev and next(if applicable) and deallocate memory */
            InstancePrev = Instance->InstanceChainPrev;
            InstanceNext = Instance->InstanceChainNext;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -