DIBSTATUS DibDriverGetMonitoringDabAudio(struct DibDriverContext * pContext, ELEM_HDL ItemHdl, union DibDataMonit * pDataMonit, uint8_t ClearMonit)
{
    struct DibDabMonitoring             * pDabMonit = (struct DibDabMonitoring *) pDataMonit;
    struct DibDriverDabAudioServiceCtx  * pService;
    FILTER_HDL                          FilterHdl  = pContext->ItemInfo[ItemHdl].ParentFilter;

    DIB_ASSERT(pDabMonit);
    DIB_ASSERT(ItemHdl < DIB_MAX_NB_ITEMS);
    DIB_ASSERT(pContext->FilterInfo[FilterHdl].TypeFilter == eDAB);
    DIB_ASSERT(((ClearMonit == eDIB_TRUE) || (ClearMonit == eDIB_FALSE)));

    DIB_DEBUG(SOFT_IF_LOG, (CRB "DibDriverGetMonitoringDabAudio" CRA));

#if (LOG_APPLICATION_TO_DRIVER_CALLS_TO_FILE == 1)
    {
        DibLogToFile_Time(gLogFile, gLogFileStartTimeSec, gLogFileStartTimeMsec);
        DibLogToFile_Mesg(gLogFile, CRB "DibDriverGetMonitoringDabAudio" CRA);
    }
#endif

    DibDriverTargetDisableIrqProcessing(pContext);

    pService = pContext->ItemInfo[ItemHdl].ItemCtx.pDabAudioService;

    if(pDabMonit)
    {
        /*** Initialize DAB Monitoring structure ***/
        DibZeroMemory(pDabMonit, sizeof(struct DibDabMonitoring));

        pDabMonit->NbPid                    = 0;
        pDabMonit->ChannelIndex             = pContext->FilterInfo[pContext->ItemInfo[ItemHdl].ParentFilter].ParentChannel;
        pDabMonit->FilterIndex              = FilterHdl;
        pDabMonit->FilterType               = pContext->FilterInfo[FilterHdl].TypeFilter;
        if(pService)
        {
            pDabMonit->CountinuityError         = pService->DabMonitoring.CountinuityError;
            pDabMonit->Error                    = pService->DabMonitoring.Error;
            pDabMonit->TotalPackets             = pService->DabMonitoring.TotalPackets;
            pDabMonit->CorrPackets              = pService->DabMonitoring.CorrectedPackets;
            /* Protected access to shared ressource, clear error and cc counts */
            if(ClearMonit == eDIB_TRUE)
                DibZeroMemory(&pService->DabMonitoring, sizeof(pService->DabMonitoring));
        }
    }
    DibDriverTargetEnableIrqProcessing(pContext);

    /* Send Message to clear internal monitoring info is sent separatly to avoid dead locks */
    if((pService) && (ClearMonit == eDIB_TRUE))
        DibDriverClearMonit(pContext, ItemHdl);

    return DIBSTATUS_SUCCESS;
}
Ejemplo n.º 2
0
U8 dib_init()
{
    struct dibI2CAdapter *i2c = open_dibcom_i2c();

    DibZeroMemory(mon, sizeof(mon));

    if (i2c == NULL)
        return 1;

#ifdef DIB7000_DEMOD_7070Q
//    if (dib7070q_attach(i2c, DIB7070PA_DEFAULT_I2C_ADDRESS, &tfe7070q_config) != DIB_RETURN_SUCCESS)
    if ((sip = dib7070q_attach(i2c, DIB7070PA_DEFAULT_I2C_ADDRESS, &tfe7070q_config)) == NULL)
#endif
#ifdef DIB7000_DEMOD_7070P
        if (dib7070pa_attach(i2c, NUM_OF_DEMOD, DIB7070PA_DEFAULT_I2C_ADDRESS, nim7070p_config, sip) != DIB_RETURN_SUCCESS)
#endif
#ifdef DIB7000_DEMOD_7070M
            if (dib7070ma_attach(i2c, NUM_OF_DEMOD, DIB7070MA_DEFAULT_I2C_ADDRESS, nim7070md_config, sip) != DIB_RETURN_SUCCESS)
#endif
            {
                DibDbgPrint("-E-  DiB7070P: attaching demod and tuners failed.\n");
                return 1;
            }

    return 0;
}
/****************************************************************************
 *  Init the bridge from the driver
 ****************************************************************************/
DIBSTATUS DibDriverTargetInit(struct DibDriverContext *pContext)
{
   struct IoctlInit pReq;

   if((pContext->DriverTargetCtx.BridgeFd = open(DEVICE_FILE_NAME, O_RDWR)) < 0) 
   {
      DIB_DEBUG(PORT_ERR, (CRB "Could not open device %s" CRA, DEVICE_FILE_NAME));
      return DIBSTATUS_ERROR;
   }

   /* this will create and initialise bridge */
   pReq.BoardHdl   = pContext->BoardHdl;
   pReq.ChipSelect = pContext->DibChip;

#if (USE_DRAGONFLY == 1)
   if((pContext->DibChip == DIB_VOYAGER) || (pContext->DibChip == DIB_NAUTILUS))
   {
     pReq.Config[0]  = pContext->DragonflyRegisters.JedecAddr;
     pReq.Config[1]  = pContext->DragonflyRegisters.JedecValue;
     pReq.Config[2]  = pContext->DragonflyRegisters.MacMbxSize;
     pReq.Config[3]  = pContext->DragonflyRegisters.MacMbxStart;
     pReq.Config[4]  = pContext->DragonflyRegisters.MacMbxEnd;
     pReq.Config[5]  = pContext->DragonflyRegisters.HostMbxSize;
     pReq.Config[6]  = pContext->DragonflyRegisters.HostMbxStart;
     pReq.Config[7]  = pContext->DragonflyRegisters.HostMbxEnd;
     pReq.Config[8]  = pContext->DragonflyRegisters.HostMbxRdPtrReg;
     pReq.Config[9]  = pContext->DragonflyRegisters.HostMbxWrPtrReg;
     pReq.Config[10] = pContext->DragonflyRegisters.MacMbxRdPtrReg;
     pReq.Config[11] = pContext->DragonflyRegisters.MacMbxWrPtrReg;
   }
   else
#endif
   DibZeroMemory(pReq.Config, sizeof(pReq.Config));

   if(ioctl(pContext->DriverTargetCtx.BridgeFd, REQUEST_BRIDGE_MODULE_INIT, &pReq) != DIBSTATUS_SUCCESS)
   {
      DIB_DEBUG(PORT_ERR, (CRB "Could initialise Bridge %s" CRA, DEVICE_FILE_NAME));

      /* close open device and free allocated memory*/
      close(pContext->DriverTargetCtx.BridgeFd);
      return DIBSTATUS_ERROR;
   }

   DibAllocateEvent(&pContext->DriverTargetCtx.IrqReadDone);
   DibInitNotificationEvent(&pContext->DriverTargetCtx.IrqReadDone);

   DibAllocateLock(&pContext->DriverTargetCtx.IrqLock);
   DibInitLock(&pContext->DriverTargetCtx.IrqLock);

   DIB_DEBUG(PORT_LOG, (CRB "Launching interrupt thread" CRA));

   pthread_create(&pContext->DriverTargetCtx.IrqThread, NULL, IntDriverTargetIrqRead, (void *)pContext);

   DibWaitForEvent(&pContext->DriverTargetCtx.IrqReadDone, 0);
   return DIBSTATUS_SUCCESS;
}
DIBSTATUS DibDriverGetMonitoringDabPacket(struct DibDriverContext * pContext, ELEM_HDL ItemHdl, union DibDataMonit * pDataMonit, uint8_t ClearMonit)
{
    struct DibDabPacketMonitoring * pMonit = (struct DibDabPacketMonitoring *) pDataMonit;
    FILTER_HDL                FilterHdl  = pContext->ItemInfo[ItemHdl].ParentFilter;
    struct DibDriverDabPacketServiceCtx  * pService;

    DIB_ASSERT(pMonit);
    DIB_ASSERT(ItemHdl < DIB_MAX_NB_ITEMS);
    DIB_ASSERT(pContext->FilterInfo[FilterHdl].TypeFilter == eDABPACKET);
    DIB_ASSERT(((ClearMonit == eDIB_TRUE) || (ClearMonit == eDIB_FALSE)));


    DibDriverTargetDisableIrqProcessing(pContext);

    pService = pContext->ItemInfo[ItemHdl].ItemCtx.pDabPacketService;

    if(pMonit)
    {
        /*** Initialize DAB Monitoring structure ***/
        DibZeroMemory(pMonit, sizeof(struct DibDabPacketMonitoring));

        pMonit->ChannelIndex             = pContext->FilterInfo[pContext->ItemInfo[ItemHdl].ParentFilter].ParentChannel;
        pMonit->FilterIndex              = FilterHdl;
        if(pService)
        {
            pMonit->MscPacketGood         = pService->DabPacketMonitoring.MscPacketGood;
            pMonit->MscPacketsError       = pService->DabPacketMonitoring.MscPacketsError;
            pMonit->DataGroupGood         = pService->DabPacketMonitoring.DataGroupGood;
            pMonit->DataGroupError        = pService->DabPacketMonitoring.DataGroupError;
            /* Protected access to shared ressource, clear error */
            if(ClearMonit == eDIB_TRUE)
                DibZeroMemory(&pService->DabPacketMonitoring, sizeof(pService->DabPacketMonitoring));
        }
    }
    DibDriverTargetEnableIrqProcessing(pContext);

    /* Send Message to clear internal monitoring info is sent separatly to avoid dead locks */
    if((pService) && (ClearMonit == eDIB_TRUE))
        DibDriverClearMonit(pContext, ItemHdl);

    DIB_DEBUG(SOFT_IF_LOG, (CRB "DibDriverGetDabPacketMonitoring %d" CRA, pMonit->FilterIndex));
    return DIBSTATUS_SUCCESS;
}
DIBSTATUS DibDriverGetMonitoringTdmb(struct DibDriverContext * pContext, ELEM_HDL ItemHdl, union DibDataMonit * pDataMonit, uint8_t ClearMonit)
{
    struct DibDabMonitoring *pDabMonit = (struct DibDabMonitoring *) pDataMonit;
    FILTER_HDL                FilterHdl  = pContext->ItemInfo[ItemHdl].ParentFilter;
    struct DibDriverFilter   *pFilter    = &pContext->FilterInfo[FilterHdl];

    DIB_ASSERT(pDabMonit);
    DIB_ASSERT(ItemHdl < DIB_MAX_NB_ITEMS);
    DIB_ASSERT(pContext->FilterInfo[FilterHdl].TypeFilter == eTDMB);
    DIB_ASSERT(((ClearMonit == eDIB_TRUE) || (ClearMonit == eDIB_FALSE)));

    DIB_DEBUG(SOFT_IF_LOG, (CRB "DibDriverGetTdmbMonitoring %d %u" CRA, FilterHdl, pFilter->DvbTMonitoring.TotalPackets));

    DibDriverTargetDisableIrqProcessing(pContext);

    /* Set external DVB-T/TDMB monitoring info */
    pDabMonit->FilterIndex              = FilterHdl;
    pDabMonit->FilterType               = pContext->FilterInfo[FilterHdl].TypeFilter;
    pDabMonit->NbPid                    = pFilter->NbActivePids;
    pDabMonit->ChannelIndex             = pFilter->ParentChannel;
    /* checker of the bridge activated */
    if(pFilter->DvbTMonitoring.CheckTotalPackets)
        pDabMonit->TotalPackets             = pFilter->DvbTMonitoring.CheckTotalPackets;
    else
        pDabMonit->TotalPackets             = pFilter->DvbTMonitoring.TotalPackets;

    pDabMonit->CountinuityError         = pFilter->DvbTMonitoring.CheckCcFailCnt;
    pDabMonit->Error                    = pFilter->DvbTMonitoring.ErrCnt;

    if(ClearMonit == eDIB_TRUE)
    {
        /* Clear Driver monitoring info */
        DibZeroMemory(&pFilter->DvbTMonitoring, sizeof(struct DvbTMonit));
    }

    DibDriverTargetEnableIrqProcessing(pContext);

    if(ClearMonit == eDIB_TRUE)
    {
        /* Clear Firmware and Bridge monitoring info */
        DibDriverClearMonit(pContext, ItemHdl);
    }

    return DIBSTATUS_SUCCESS;
}
DIBSTATUS DibDriverDragonflyAddItemMpeIFec(struct DibDriverContext *pContext, union DibFilters *pFilterDesc, FILTER_HDL FilterHdl, uint32_t ItemHdl, struct MsgCreateItem * msg)
{
   struct DibDriverMpeIFecServiceCtx *pMpeIFecService;
   struct DibDriverItem              *pItem;

   msg->Param.Mpeifec.Pid                 = pFilterDesc->MpeIFec.Pid;
   msg->Param.Mpeifec.MaxBurstDuration    = pFilterDesc->MpeIFec.MaxBurstDuration;
   msg->Param.Mpeifec.Prefetch            = pFilterDesc->MpeIFec.Prefetch;
   msg->Param.Mpeifec.B                   = pFilterDesc->MpeIFec.EncodParal;
   msg->Param.Mpeifec.C                   = pFilterDesc->MpeIFec.NbAdstColumns;
   msg->Param.Mpeifec.S                   = pFilterDesc->MpeIFec.SpreadingFactor;
   msg->Param.Mpeifec.R                   = pFilterDesc->MpeIFec.MaxIFecSect;
   msg->Param.Mpeifec.D                   = pFilterDesc->MpeIFec.SendingDelay;

   pMpeIFecService = (struct DibDriverMpeIFecServiceCtx *) DibMemAlloc(sizeof(struct DibDriverMpeIFecServiceCtx));
   pItem = &pContext->ItemInfo[ItemHdl];
   pItem->ItemCtx.pMpeIFecService = pMpeIFecService;

   if(pMpeIFecService == NULL)
   {
      DIB_DEBUG(SOFT_IF_ERR, (CRB "IntDriverAddPid: no memory for MPE-IFEC service" CRA));
      return DIBSTATUS_ERROR;
   }

   pMpeIFecService->RsNumRows               = pFilterDesc->MpeIFec.NbRows;
   pMpeIFecService->Pid                     = pFilterDesc->MpeIFec.Pid;
   pMpeIFecService->OnlyIfPrioritaryChannel = pContext->ChannelInfo[pContext->FilterInfo[FilterHdl].ParentChannel].IsDataChannel;
   pMpeIFecService->MaxBurstDuration        = pFilterDesc->MpeIFec.MaxBurstDuration;

   /* TBD_IF */

   DibZeroMemory(&pMpeIFecService->DvbSHMonitoring, sizeof(struct DvbSHMonit));

   pContext->FilterInfo[FilterHdl].NbActivePids++;

   return DIBSTATUS_SUCCESS;
}
/**
 * Get MpeIFec Data monitoring
 * @param[in] pContext: driver context
 * @param[in] ItemHdl: filter item handler.
 * @param[out] pDVBMonit: DVB-SH monitoring information of the corresponding item
 * @param[in] ClearMonit: Reset internal monitoring information after retreiving them.
 */
DIBSTATUS DibDriverGetMonitoringMpeIFec(struct DibDriverContext *pContext, ELEM_HDL ItemHdl, union DibDataMonit *pDataMonit, uint8_t ClearMonit)
{
   struct DibDvbSHMonitoring         *pDvbSHMonit = (struct DibDvbSHMonitoring *) pDataMonit;
   struct DibDriverMpeIFecServiceCtx *pMpeIFecService;     /* Points to MPE service context if target MPE. pMpeService_CONTEXT*/
   FILTER_HDL                         FilterHdl  = pContext->ItemInfo[ItemHdl].ParentFilter;

   DIB_ASSERT(pDvbSHMonit);
   DIB_ASSERT(ItemHdl < DIB_MAX_NB_ITEMS);
   DIB_ASSERT(pContext->FilterInfo[FilterHdl].TypeFilter == eMPEIFEC);
   DIB_ASSERT(((ClearMonit == eDIB_TRUE) || (ClearMonit == eDIB_FALSE)));
   
   DIB_DEBUG(SOFT_IF_LOG, (CRB "DibDriverGetDVBSHMonitoring" CRA));

#if (LOG_APPLICATION_TO_DRIVER_CALLS_TO_FILE == 1)
   {
      DibLogToFile_Time(gLogFile, gLogFileStartTimeSec, gLogFileStartTimeMsec);
      DibLogToFile_Mesg(gLogFile, CRB "DibDriverGetDVBSHMonitoring" CRA);
   }
#endif

   DibDriverTargetDisableIrqProcessing(pContext);

   pMpeIFecService = pContext->ItemInfo[ItemHdl].ItemCtx.pMpeIFecService;

   if(pMpeIFecService)
   {
      if(pDvbSHMonit)
      {
         /*** Initialize DVBH Monitoring structure ***/
         DibZeroMemory(pDvbSHMonit, sizeof(struct DibDvbSHMonitoring));

         pDvbSHMonit->Pid                    = pContext->ItemInfo[ItemHdl].Config.MpeIFec.Pid;
         pDvbSHMonit->ChannelIndex           = pContext->FilterInfo[pContext->ItemInfo[ItemHdl].ParentFilter].ParentChannel;
         pDvbSHMonit->FilterIndex            = FilterHdl;

         pDvbSHMonit->NbRows                 = pContext->ItemInfo[ItemHdl].Config.MpeIFec.NbRows;
         pDvbSHMonit->EncodParal             = pContext->ItemInfo[ItemHdl].Config.MpeIFec.EncodParal;
         pDvbSHMonit->SpreadingFactor        = pContext->ItemInfo[ItemHdl].Config.MpeIFec.SpreadingFactor;
         pDvbSHMonit->SendingDelay           = pContext->ItemInfo[ItemHdl].Config.MpeIFec.SendingDelay;
         pDvbSHMonit->NbAdstColumns          = pContext->ItemInfo[ItemHdl].Config.MpeIFec.NbAdstColumns;
         pDvbSHMonit->MaxIFecSect            = pContext->ItemInfo[ItemHdl].Config.MpeIFec.MaxIFecSect;

         pDvbSHMonit->AdstTotalTables        = pMpeIFecService->DvbSHMonitoring.AdstTotalTables;    
         pDvbSHMonit->AdstTablesLost         = pMpeIFecService->DvbSHMonitoring.AdstTablesLost;     
         pDvbSHMonit->AdstTablesCorrected    = pMpeIFecService->DvbSHMonitoring.AdstTablesCorrected;
         pDvbSHMonit->AdstTablesFailed       = pMpeIFecService->DvbSHMonitoring.AdstTablesFailed;   
         pDvbSHMonit->AdstTablesGood         = pMpeIFecService->DvbSHMonitoring.AdstTablesGood;

         pDvbSHMonit->AdtTotalTables         = pMpeIFecService->DvbSHMonitoring.AdtTotalTables;     
         pDvbSHMonit->AdtTablesCorrected     = pMpeIFecService->DvbSHMonitoring.AdtTablesCorrected; 
         pDvbSHMonit->AdtTablesFailed        = pMpeIFecService->DvbSHMonitoring.AdtTablesFailed;    
         pDvbSHMonit->AdtTablesGood          = pMpeIFecService->DvbSHMonitoring.AdtTablesGood;      

         pDvbSHMonit->DeltaTStream           = pMpeIFecService->DvbSHMonitoring.DeltaTStream;
         pDvbSHMonit->DeltaTDetected         = pMpeIFecService->DvbSHMonitoring.DeltaTDetected;
         pDvbSHMonit->BurstStream            = pMpeIFecService->DvbSHMonitoring.BurstStream;
         pDvbSHMonit->BurstDetected          = pMpeIFecService->DvbSHMonitoring.BurstDetected;
         pDvbSHMonit->PowerUpTime            = pMpeIFecService->DvbSHMonitoring.PowerUpTime; 

         pDvbSHMonit->CountinuityError       = pMpeIFecService->DvbSHMonitoring.CcFailCnt;
         pDvbSHMonit->Error                  = pMpeIFecService->DvbSHMonitoring.ErrCnt;
      }

      /* Protected access to shared ressource, clear error and cc counts */
      if(ClearMonit)
         DibZeroMemory(&pMpeIFecService->DvbSHMonitoring, sizeof(pMpeIFecService->DvbSHMonitoring));
   }

   DibDriverTargetEnableIrqProcessing(pContext);

   /* Send Message to clear internal monitoring info is sent separatly to avoid dead locks */
   if((pMpeIFecService) && (ClearMonit == eDIB_TRUE))
      DibDriverClearMonit(pContext, ItemHdl);

   return DIBSTATUS_SUCCESS;
}
Ejemplo n.º 8
0
/* example of creating all the demod-structure and tuner-structures and tuning them in diversity and start monitoring after that */
int main(int argc, char *argv[])
{
    struct dibI2CAdapter *main_i2c = open_spp_i2c();
    struct dibI2CAdapter *tuner_i2c[2];
    struct dibDemod *demod[2];
    struct dibTuner *tuner[2];

    struct dibDemodMonitor mon[2];

    struct dibDVBChannel ch;

    DibZeroMemory(mon, sizeof(mon));

    if (main_i2c == NULL)
        return 1;

    /* attach 2 demods, do i2c-enumeration */
    if (dib7000p_attach(main_i2c, 2, DEFAULT_DIB7000P_I2C_ADDRESS, 1, dib7000p_example_board_config, demod) != 0) {
        DibDbgPrint("-E-  dib7000 attaching and i2c enumeration failed.\n");
        exit(1);
    }

    /* first tuner */
    tuner_i2c[0] = dib7000p_get_i2c_master(demod[0], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[0] = env57h12d5_attach(tuner_i2c[0], &tuner_0_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -0- attaching failed.\n");
        exit(1);
    }

    /* second tuner */
    tuner_i2c[1] = dib7000p_get_i2c_master(demod[1], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[1] = env57h12d5_attach(tuner_i2c[1], &tuner_1_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -1- attaching failed.\n");
        exit(1);
    }

    INIT_DVB_CHANNEL(&ch);
    ch.RF_kHz = 474000;
    ch.Bw     = INDEX_BW_8_0_MHZ;

    /* tune the 2 demods and tuner to the channel "ch" */
    tune_diversity_tuner_and_demod(tuner,demod,2,&ch);

    DibDbgPrint("-I-  Tuning done <enter>\n");
    getchar();

    while (1) {
        /* get monitoring information for the first demod */
        demod_get_monitoring(demod[0], &mon[0]);
        /* get monitoring information for the second demod */
        demod_get_monitoring(demod[1], &mon[1]);
        /* display information for 2 demods */
        dib7000_print_monitor(mon, NULL, 0, 2);
        usleep(100000);
    }

    DibDbgPrint("-I-  Cleaning up\n");

    /* release the 2 tuners */
    tuner_release(tuner[1]);
    tuner_release(tuner[0]);

    /* release the 2 demods */
    demod_release(demod[1]);
    demod_release(demod[0]);

    close_spp_i2c();

    return 0;
}
Ejemplo n.º 9
0
/* example of creating all the demod-structure and tuner-structures and tuning them in diversity and start monitoring after that */
int main(int argc, char *argv[])
{
    struct dibI2CAdapter *main_i2c = open_spp_i2c();
    struct dibI2CAdapter *tuner_i2c[2];
    struct dibDemod *demod[2];
    struct dibTuner *tuner[2];

    struct dibDemodMonitor mon[2];

    struct dibDVBChannel ch;

    DibZeroMemory(mon, sizeof(mon));

    if (main_i2c == NULL)
        return 1;

    if (dib7000m_attach(main_i2c, 2, DEFAULT_DIB7000M_I2C_ADDRESS, 1, dib7000m_demod_config, demod) != 0) {
        DibDbgPrint("-E-  dib7000 attaching and i2c enumeration failed.\n");
        exit(1);
    }

    tuner_i2c[0] = dib7000m_get_i2c_master(demod[0], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[0] = env57h12d5_attach(tuner_i2c[0], &tuner_0_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -0- attaching failed.\n");
        exit(1);
    }

    tuner_i2c[1] = dib7000m_get_i2c_master(demod[1], DIBX000_I2C_INTERFACE_TUNER, 1);
    if ((tuner[1] = env57h12d5_attach(tuner_i2c[1], &tuner_1_config)) == NULL) {
        DibDbgPrint("-E-  env57h12d5 -1- attaching failed.\n");
        exit(1);
    }

    INIT_DVB_CHANNEL(&ch);
    ch.RF_kHz = 474000;
    ch.Bw     = INDEX_BW_8_0_MHZ;

    tune_diversity_tuner_and_demod(tuner,demod,2,&ch);

    DibDbgPrint("-I-  Tuning done <enter>\n");
    getchar();

    while (1) {
        demod_get_monitoring(demod[0], &mon[0]);
        demod_get_monitoring(demod[1], &mon[1]);
        dib7000_print_monitor(mon, NULL, 0, 2);
        usleep(100000);
    }

    DibDbgPrint("-I-  Cleaning up\n");

    tuner_release(tuner[1]);
    tuner_release(tuner[0]);

    demod_release(demod[1]);
    demod_release(demod[0]);

    close_spp_i2c();

    return 0;
}
/*-----------------------------------------------------------------------
|  Open the Device Driver
-----------------------------------------------------------------------*/
static int32_t DibBridgeTargetModuleOpen(struct inode *inode, struct file *file)
{
   int32_t                  status         = DIBSTATUS_ERROR;
   struct DibBridgeContext *pBridgeContext = NULL;
   printk(CRB "Trying to open dibbridge..");

   pBridgeContext = (struct DibBridgeContext *) DibBridgeTargetAllocBuf(sizeof(struct DibBridgeContext));

   if(pBridgeContext == NULL)
   {
      printk(CRB "%s: Out of memory" CRA, __func__);
      return -ENOMEM;
   }

   /* Clear Content */
   DibZeroMemory(pBridgeContext, sizeof(struct DibBridgeContext));

   /* Allocate ptr for IOCTL request */
   pBridgeContext->BridgeTargetCtx.IoctlReq = kmalloc(sizeof(struct IoctlHead), GFP_KERNEL);

   if(pBridgeContext->BridgeTargetCtx.IoctlReq == NULL) 
   {
      printk(CRB "%s: Out of memory" CRA, __func__);
      status =  -ENOMEM;
      goto End;
   }

   /* Allocate buffer for IOCTL request */
   pBridgeContext->BridgeTargetCtx.IoctlReq->Buffer = kmalloc(MAX_BRIDGE_DRIVER_BUFFER, GFP_KERNEL);

   if(pBridgeContext->BridgeTargetCtx.IoctlReq->Buffer == NULL) 
   {
      printk(CRB "%s: Out of memory" CRA, __func__);
      status =  -ENOMEM;
      goto End;
   }

   /* Init IOCTL Lock */
   DibAllocateLock(&pBridgeContext->BridgeTargetCtx.IoctlLock);
   DibInitLock(&pBridgeContext->BridgeTargetCtx.IoctlLock);

   status = DIBSTATUS_SUCCESS;

End:
   if(status != DIBSTATUS_SUCCESS)
   {
      /* Free possibly allocated struct */
      IntBridgeTargetModuleFreeStruct(pBridgeContext);
   }
   else
   {
      status = (int32_t)DIBSTATUS_SUCCESS;

      /* Store Allocated Bridge Context */
      file->private_data = pBridgeContext;

   try_module_get(THIS_MODULE);
   }

   return status;
}
Ejemplo n.º 11
0
void frontend_init(struct dibFrontend *fe)
{
	DibZeroMemory(fe,sizeof(struct dibFrontend));
}
Ejemplo n.º 12
0
/* both demods are on the same I2C-bus by default accessible through address 18 */
int main (void)
{
    // default I2C implementation is based on parallel port but user can connect its
    // own I2C driver using host_i2c_interface_attach();
    // implementation is done in sample/interface/host.c
    //struct dibDataBusHost *i2c = host_i2c_interface_attach(NULL), *b;
    struct dibDataBusHost *i2c = open_spp_i2c(), *b;
    struct dibFrontend frontend[2];

    struct dibChannel ch;
    struct dibDemodMonitor mon[2];
    struct dibPMU *pmu;

    if (i2c == NULL)
        return 1;
    DibZeroMemory(&mon, sizeof(mon));

    frontend_init(&frontend[0]); /* initializing the frontend-structure */
    frontend_init(&frontend[1]); /* initializing the frontend-structure */
    frontend_set_id(&frontend[0], 0); /* assign an absolute ID to the frontend */
    frontend_set_id(&frontend[1], 1); /* assign an absolute ID to the frontend */

    if (dib9090_firmware_sip_register(&frontend[0], 0x80, i2c, &nim9090md_config[0]) == NULL) { /* using a frontend on I2C address 0x80 */
        dbgp(" DiB9090: attaching demod and tuners failed.\n");
        return DIB_RETURN_ERROR;
    }
    i2c = dib7000m_get_i2c_master(&frontend[0], DIBX000_I2C_INTERFACE_GPIO_3_4, 0);
    if (dib9090_firmware_sip_register(&frontend[1], 0x82, i2c, &nim9090md_config[1]) == NULL) { /* using a frontend on I2C address 0x82 */
        dbgp(" DiB9090: attaching demod and tuners failed.\n");
        return DIB_RETURN_ERROR;
    }

    /* do the i2c-enumeration for 2 demod and use 0x80 as the I2C address for first device */
    i2c = data_bus_client_get_data_bus(demod_get_data_bus_client(&frontend[0]));
    dib7000m_i2c_enumeration(i2c, 1, 0x20, 0x80); /* non-standard i2c-enumeration, because of INT_SELECT-fixation */
    i2c = data_bus_client_get_data_bus(demod_get_data_bus_client(&frontend[1]));
    dib7000m_i2c_enumeration(i2c, 1, DEFAULT_DIB9000_I2C_ADDRESS, 0x82);

    b = dib7000m_get_i2c_master(&frontend[0], DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
    if ((pmu = osiris_create(b, &nim9090md_osiris_config)) == NULL)
        return DIB_RETURN_ERROR;
    dib9090_set_pmu(&frontend[0], pmu); /* workaround because we cannot access the PMU from the host after downloading the firmware - for now */

    frontend_reset(&frontend[0]);
    frontend_reset(&frontend[1]);

    INIT_CHANNEL(&ch, STANDARD_DVBT);
    ch.RF_kHz = 474000;
    ch.bandwidth_kHz = 8000;

/* just to set them in a known state - not important */
    tune_diversity(frontend, 2, &ch);

    DibDbgPrint("-I-  Tuning done <enter>\n");
    getchar();

    while (1) {
        /* after enumerating on the same i2c-bus, the i2c-addresses of the bus will be 0x80 for the diversity master and 0x82 for the slave */
        demod_get_monitoring(&frontend[0], &mon[0]);
        demod_get_monitoring(&frontend[1], &mon[1]);
        dib7000_print_monitor(mon, NULL, 0 ,2);
        usleep(100000);
    }

    DibDbgPrint("-I-  Cleaning up\n");

    frontend_unregister_components(&frontend[1]);
    frontend_unregister_components(&frontend[0]);
    pmu_release(pmu);

    //host_i2c_release(i2c);
    close_spp_i2c();

    return 0;
}