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

📄 demod_hamaro.c

📁 机顶盒Hamaro解调器驱动。包含自动搜台
💻 C
📖 第 1 页 / 共 5 页
字号:

        case CONNECTED:
            break;

        case UNINITIALIZED:
        case DISCONNECTED:
        default:
            break;
    }
}

/*****************************************************************************/
/*  FUNCTION:    hamaro_interrupt_msg                                         */
/*                                                                           */
/*  PARAMETERS:  None.                                                       */
/*                                                                           */
/*  DESCRIPTION: This function implements the processing required on receipt */
/*               of an INTERRUPT message.                                    */
/*                                                                           */
/*  RETURNS:     Nothing.                                                    */
/*                                                                           */
/*  CONTEXT:     Will be run in task context.                                */
/*                                                                           */
/*****************************************************************************/
static void hamaro_interrupt_msg( void )
{
    int ii;
    INTEROPTS pending;

    trace_new( TL_FUNC, "New Hamaro interrupt message\n" );

    for ( ii=0; ii<local_unit_count; ++ii )
    {
        trace_new( TL_VERBOSE, "Pending interrupts for unit %d: 0x%02x\n", ii, pending );

        /* Hamaro_Monitor does not work so using    API_GetLockIndicators instead*/
        API_GetLockIndicators(&NIMs[ii],&NewLock[ii]);
        if (NewLock[ii].reedsolomon == TRUE)
        {
            NewAcqState[ii] = ACQ_LOCKED_AND_TRACKING;
        }
        else
        {
             NewAcqState[ii] = ACQ_FADE;
        }

        switch( local_state[ii] )
        {
            case CONNECTING:
            case CONT_CONNECTING:
                hamaro_connecting_state( ii, pending, OldAcqState[ii], NewAcqState[ii] );
                break;

            case CONNECTED:
                hamaro_connected_state( ii, pending, OldAcqState[ii], NewAcqState[ii] );
                break;

            case SCANNING:
                hamaro_scanning_state( ii, pending, OldAcqState[ii], NewAcqState[ii] );
                break;

            case FADE:
                hamaro_fade_state( ii, pending, OldAcqState[ii], NewAcqState[ii] );
                break;

            /* Interrupts in unexpected states can be ignored.  The ISR already
               disabled any further interrupts. */
            case UNINITIALIZED:
            case DISCONNECTED:
            default:
                break;
        }

        /* New (current) state becomes the old state. */
        OldAcqState[ii] = NewAcqState[ii];
        OldLock[ii] = NewLock[ii];
    }
}

/*****************************************************************************/
/*  FUNCTION:    hamaro_connect_msg                                           */
/*                                                                           */
/*  PARAMETERS:  unit - the unit specified in the CONNECT message.           */
/*               tune - the tuning specification in the CONNECT messsage.    */
/*                                                                           */
/*  DESCRIPTION: This function implements the processing required on receipt */
/*               of a CONNECT message.                                       */
/*                                                                           */
/*  RETURNS:     Nothing.                                                    */
/*                                                                           */
/*  CONTEXT:     Will be run in task context.                                */
/*                                                                           */
/*****************************************************************************/
static void hamaro_connect_msg( u_int32 unit, TUNING_SPEC *tune )
{
    CHANOBJ chan;
    int api_error;
    DEMOD_CALLBACK_DATA parm;
    BOOL APIresult;
    int rc;
    CMPLXNO esno;
    MSTATUS status;

    trace_new( TL_FUNC, "New connect message for unit %d\n", unit );

    local_state[unit] = CONNECTING;
    NewAcqState[unit] = OldAcqState[unit] = ACQ_FADE;

    chan.frequency = tune->tune.nim_satellite_tune.frequency;
    chan.modtype = MOD_QPSK;
     if((tune->tune.nim_satellite_tune.fec != M_RATE_AUTO)&&
     			(tune->tune.nim_satellite_tune.fec != M_RATE_NONE))
     {
          /* Manual mode. */
          chan.coderate = xlat_fec_in( tune->tune.nim_satellite_tune.fec );       
          /* Not sure why we do this but I'll leave it there as it dosent cause much harm! */
          chan.viterbicoderates = CODERATE_2DIV3 | CODERATE_3DIV4; /* only for testing - should be 0 */
     }
     else
     {
         /* Automatic mode, try all code rates. */
         chan.coderate = CODERATE_1DIV2;
          chan.viterbicoderates = viterbicoderates;
     }
    chan.symbrate = tune->tune.nim_satellite_tune.symbol_rate;
    chan.specinv = xlat_spectrum_in( tune->tune.nim_satellite_tune.spectrum );
    //chan.samplerate = SAMPLE_FREQ_NOM;
    chan.transpec = SPEC_DVB;
    /* Hack H/V reverse */

    //chan.lnbtone =  LNBTONE_OFF;
    
    /* Make sure all interrupts (including acq_fail) are reset, then call
       API_ChangeChannel to accomplish the tuning. */
    API_AcqBegin( &NIMs[unit] );
    acq_failure_countdown[unit] = DEMOD_CONNECT_COUNTDOWN;
    APIresult = API_ChangeChannel( &NIMs[unit], &chan );
    if ( APIresult )
    {
        trace_new( TL_VERBOSE, "API_ChangeChannel succeeded for unit %d\n", unit );


        /* Start the demod monitoring signal quality. */
        if ( !API_GetChannelEsNo( &NIMs[0], ESNOMODE_SNAPSHOT, &esno, &status ) )
        {
            trace_new( TL_ERROR, "API_GetChannelEsNo failed\n" );
            trace_new( TL_ERROR, "File: %s, line: %d\n", API_GetErrorFilename(&NIMs[0]), API_GetErrorLineNumber(&NIMs[0]) );
            api_error = API_GetLastError( &NIMs[0] );
            trace_new( TL_ERROR, "Error %d, %s\n", api_error, API_GetErrorMessage(&NIMs[0], (APIERRNO)api_error) );
        }
    
        rc = tick_set( hHamaroTick[unit], HAMARO_CONNECTING_TIMEOUT, TRUE );
        if ( rc != RC_OK )
        {
            trace_new( TL_ERROR, "Hamaro can't set tick timer for connect message!\n" );
            error_log( ERROR_FATAL | RC_SDM_SYSERR );
        }
        else
        {
            rc = tick_start( hHamaroTick[unit] );
            if ( rc != RC_OK )
            {
                trace_new( TL_ERROR, "Hamaro can't start tick timer for connect message!\n" );
                error_log( ERROR_FATAL | RC_SDM_SYSERR );
            }
        }
    }
    else
    {
        trace_new( TL_ERROR, "API_ChangeChannel failed for unit %d\n", unit );
        trace_new( TL_ERROR, "File: %s, line: %d\n", API_GetErrorFilename(&NIMs[unit]), API_GetErrorLineNumber(&NIMs[unit]) );
        api_error = API_GetLastError( &NIMs[unit] );
        trace_new( TL_ERROR, "Error %d, %s\n", api_error, API_GetErrorMessage(&NIMs[unit], (APIERRNO)api_error) );
        if ( callbacks[unit] )
        {
            parm.parm.type = DEMOD_FAILED;
            callbacks[unit]( my_module, unit, DEMOD_CONNECT_STATUS, &parm );
        }
    }
}

/*****************************************************************************/
/*  FUNCTION:    hamaro_disconnect_msg                                        */
/*                                                                           */
/*  PARAMETERS:  unit - the unit specified in the DISCONNECT message.        */
/*                                                                           */
/*  DESCRIPTION: This function implements the processing required on receipt */
/*               of a DISCONNECT message.                                    */
/*                                                                           */
/*  RETURNS:     Nothing.                                                    */
/*                                                                           */
/*  CONTEXT:     Will be run in task context.                                */
/*                                                                           */
/*****************************************************************************/
static void hamaro_disconnect_msg( u_int32 unit )
{
    DEMOD_CALLBACK_DATA parm;

    trace_new( TL_FUNC, "New disconnect message for unit %d\n", unit );

    //API_SetInterruptOptions( &NIMs[unit], HAMARO_NO_INTERRUPTS );
    local_state[unit] = DISCONNECTED;

    if ( callbacks[unit] )
    {
        parm.parm.type = DEMOD_DISCONNECTED;
        callbacks[unit]( my_module, unit, DEMOD_DISCONNECT_STATUS, &parm );
    }
}

/*****************************************************************************/
/*  FUNCTION:    hamaro_scan_msg                                              */
/*                                                                           */
/*  PARAMETERS:  unit - the unit specified in the SCAN message.              */
/*               scan - the scanning specification in the SCAN messsage.     */
/*                                                                           */
/*  DESCRIPTION: This function implements the processing required on receipt */
/*               of a SCAN message.                                          */
/*                                                                           */
/*  RETURNS:     Nothing.                                                    */
/*                                                                           */
/*  CONTEXT:     Will be run in task context.                                */
/*                                                                           */
/*****************************************************************************/
static void hamaro_scan_msg( u_int32 unit, SCAN_SPEC *scan )
{
    CHANOBJ chan;
    int api_error;
    DEMOD_CALLBACK_DATA parm;
    BOOL APIresult;
    int rc;
    int ii;
    CMPLXNO esno;
    MSTATUS status;

    trace_new( TL_FUNC, "New scan message for unit %d\n", unit );

    /* Change state to scanning, and remember the parameters for the operation. */
    local_state[unit] = SCANNING;
    local_scan[unit] = *scan;

    /* Set the current frequency to the initial frequency, and set the current
       indices for symbol rate and polarity searches. */
    local_scan[unit].current.type = DEMOD_NIM_SATELLITE;
    scan_parms[unit].current_frequency = scan->scan.satellite.start_frequency;
    local_scan[unit].current.tune.nim_satellite_tune.frequency = scan_parms[unit].current_frequency;
    scan_parms[unit].current_symbol_rate = 0;
    local_scan[unit].current.tune.nim_satellite_tune.fec = scan->scan.satellite.fecs[0];
    scan_parms[unit].current_polarity = 0;
    local_scan[unit].current.tune.nim_satellite_tune.polarisation = scan->scan.satellite.polarizations[0];

    /* Make a local copy of the symbol rate search list. */
    local_scan[unit].scan.satellite.symbol_rates = &local_symrates[unit][0];
    local_scan[unit].current.tune.nim_satellite_tune.symbol_rate = scan->scan.satellite.symbol_rates[0];
    for ( ii=0; ii<scan->scan.satellite.num_symrates; ++ii )
    {
        local_symrates[unit][ii] = scan->scan.satellite.symbol_rates[ii];
    }

    /* Make a local copy of the polarizations search list. */
    local_scan[unit].scan.satellite.polarizations = &local_polarizations[unit][0];
    local_scan[unit].current.tune.nim_satellite_tune.polarisation = scan->scan.satellite.polarizations[0];
    for ( ii=0; ii<scan->scan.satellite.num_pols; ++ii )
    {
        local_polarizations[unit][ii] = scan->scan.satellite.polarizations[ii];
    }

    /* Form the viterbi search mask from the viterbi search list. */
    local_viterbis[unit] = 0;
    for ( ii=0; ii<scan->scan.satellite.num_fecs; ++ii )
    {
        local_viterbis[unit] |= xlat_fec_in( scan->scan.satellite.fecs[ii] );
    }

    local_tuning[unit] = local_scan[unit].current;

    cnxt_set_lnb( &NIMs[unit], &local_scan[unit].current, &chan.frequency );
    chan.modtype = MOD_QPSK;
    chan.coderate = xlat_fec_in( local_scan[unit].current.tune.nim_satellite_tune.fec );
    chan.symbrate = local_scan[unit].current.tune.nim_satellite_tune.symbol_rate;
    chan.specinv = SPEC_INV_ON_BOTH; /* Fix me! wjj */
   

⌨️ 快捷键说明

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