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

📄 linux_dvb.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 3 页
字号:
        msg_Dbg(p_access, "  forward error correction 6/7");    if( p_frontend->info.caps & FE_CAN_FEC_7_8)        msg_Dbg(p_access, "  forward error correction 7/8");    if( p_frontend->info.caps & FE_CAN_FEC_8_9)        msg_Dbg(p_access, "  forward error correction 8/9");    if( p_frontend->info.caps & FE_CAN_FEC_AUTO)        msg_Dbg(p_access, "  forward error correction auto");    if( p_frontend->info.caps & FE_CAN_QPSK)        msg_Dbg(p_access, "  card can do QPSK");    if( p_frontend->info.caps & FE_CAN_QAM_16)        msg_Dbg(p_access, "  card can do QAM 16");    if( p_frontend->info.caps & FE_CAN_QAM_32)        msg_Dbg(p_access, "  card can do QAM 32");    if( p_frontend->info.caps & FE_CAN_QAM_64)        msg_Dbg(p_access, "  card can do QAM 64");    if( p_frontend->info.caps & FE_CAN_QAM_128)        msg_Dbg(p_access, "  card can do QAM 128");    if( p_frontend->info.caps & FE_CAN_QAM_256)        msg_Dbg(p_access, "  card can do QAM 256");    if( p_frontend->info.caps & FE_CAN_QAM_AUTO)        msg_Dbg(p_access, "  card can do QAM auto");    if( p_frontend->info.caps & FE_CAN_TRANSMISSION_MODE_AUTO)        msg_Dbg(p_access, "  transmission mode auto");    if( p_frontend->info.caps & FE_CAN_BANDWIDTH_AUTO)        msg_Dbg(p_access, "  bandwidth mode auto");    if( p_frontend->info.caps & FE_CAN_GUARD_INTERVAL_AUTO)        msg_Dbg(p_access, "  guard interval mode auto");    if( p_frontend->info.caps & FE_CAN_HIERARCHY_AUTO)        msg_Dbg(p_access, "  hierarchy mode auto");    if( p_frontend->info.caps & FE_CAN_MUTE_TS)        msg_Dbg(p_access, "  card can mute TS");    if( p_frontend->info.caps & FE_CAN_RECOVER)        msg_Dbg(p_access, "  card can recover from a cable unplug");    msg_Dbg(p_access, "End of capability list");    return VLC_SUCCESS;}/***************************************************************************** * Decoding the DVB parameters (common) *****************************************************************************/static fe_spectral_inversion_t DecodeInversion( access_t *p_access ){    vlc_value_t         val;    fe_spectral_inversion_t fe_inversion = 0;    var_Get( p_access, "dvb-inversion", &val );    msg_Dbg( p_access, "using inversion=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_inversion = INVERSION_OFF; break;        case 1: fe_inversion = INVERSION_ON; break;        case 2: fe_inversion = INVERSION_AUTO; break;        default:            msg_Dbg( p_access, "dvb has inversion not set, using auto");            fe_inversion = INVERSION_AUTO;            break;    }    return fe_inversion;}static fe_code_rate_t DecodeFEC( access_t *p_access, int i_val ){    fe_code_rate_t      fe_fec = FEC_NONE;    msg_Dbg( p_access, "using fec=%d", i_val );    switch( i_val )    {        case 0: fe_fec = FEC_NONE; break;        case 1: fe_fec = FEC_1_2; break;        case 2: fe_fec = FEC_2_3; break;        case 3: fe_fec = FEC_3_4; break;        case 4: fe_fec = FEC_4_5; break;        case 5: fe_fec = FEC_5_6; break;        case 6: fe_fec = FEC_6_7; break;        case 7: fe_fec = FEC_7_8; break;        case 8: fe_fec = FEC_8_9; break;        case 9: fe_fec = FEC_AUTO; break;        default:            /* cannot happen */            fe_fec = FEC_NONE;            msg_Err( p_access, "argument has invalid FEC (%d)", i_val);            break;    }    return fe_fec;}static fe_modulation_t DecodeModulation( access_t *p_access ){    vlc_value_t         val;    fe_modulation_t     fe_modulation = 0;    var_Get( p_access, "dvb-modulation", &val );    switch( val.i_int )    {        case -1: fe_modulation = QPSK; break;        case 0: fe_modulation = QAM_AUTO; break;        case 16: fe_modulation = QAM_16; break;        case 32: fe_modulation = QAM_32; break;        case 64: fe_modulation = QAM_64; break;        case 128: fe_modulation = QAM_128; break;        case 256: fe_modulation = QAM_256; break;        default:            msg_Dbg( p_access, "terrestrial/cable dvb has constellation/modulation not set, using auto");            fe_modulation = QAM_AUTO;            break;    }    return fe_modulation;}/***************************************************************************** * FrontendSetQPSK : controls the FE device *****************************************************************************/static fe_sec_voltage_t DecodeVoltage( access_t *p_access ){    vlc_value_t         val;    fe_sec_voltage_t    fe_voltage;    var_Get( p_access, "dvb-voltage", &val );    msg_Dbg( p_access, "using voltage=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_voltage = SEC_VOLTAGE_OFF; break;        case 13: fe_voltage = SEC_VOLTAGE_13; break;        case 18: fe_voltage = SEC_VOLTAGE_18; break;        default:            fe_voltage = SEC_VOLTAGE_OFF;            msg_Err( p_access, "argument has invalid voltage (%d)", val.i_int );            break;    }    return fe_voltage;}static fe_sec_tone_mode_t DecodeTone( access_t *p_access ){    vlc_value_t         val;    fe_sec_tone_mode_t  fe_tone;    var_Get( p_access, "dvb-tone", &val );    msg_Dbg( p_access, "using tone=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_tone = SEC_TONE_OFF; break;        case 1: fe_tone = SEC_TONE_ON; break;        default:            fe_tone = SEC_TONE_OFF;            msg_Err( p_access, "argument has invalid tone mode (%d)", val.i_int);            break;    }    return fe_tone;}struct diseqc_cmd_t{    struct dvb_diseqc_master_cmd cmd;    uint32_t wait;};static int DoDiseqc( access_t *p_access ){    access_sys_t *p_sys = p_access->p_sys;    vlc_value_t val;    int i_frequency, i_lnb_slof;    fe_sec_voltage_t fe_voltage;    fe_sec_tone_mode_t fe_tone;    int i_err;    var_Get( p_access, "dvb-frequency", &val );    i_frequency = val.i_int;    var_Get( p_access, "dvb-lnb-slof", &val );    i_lnb_slof = val.i_int;    var_Get( p_access, "dvb-tone", &val );    if( val.i_int == -1 /* auto */ )    {        if( i_frequency >= i_lnb_slof )            val.i_int = 1;        else            val.i_int = 0;        var_Set( p_access, "dvb-tone", val );    }    fe_voltage = DecodeVoltage( p_access );    fe_tone = DecodeTone( p_access );    /* Switch off continuous tone. */    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_TONE, SEC_TONE_OFF )) < 0 )    {        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %s",                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err,                 strerror(errno) );        return i_err;    }    /* Configure LNB voltage. */    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_VOLTAGE, fe_voltage )) < 0 )    {        msg_Err( p_access, "ioctl FE_SET_VOLTAGE failed, voltage=%d (%d) %s",                 fe_voltage, i_err, strerror(errno) );        return i_err;    }    var_Get( p_access, "dvb-high-voltage", &val );    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_ENABLE_HIGH_LNB_VOLTAGE,                        val.b_bool )) < 0 && val.b_bool )    {        msg_Err( p_access,                 "ioctl FE_ENABLE_HIGH_LNB_VOLTAGE failed, val=%d (%d) %s",                 val.b_bool, i_err, strerror(errno) );    }    /* Wait for at least 15 ms. */    msleep(15000);    var_Get( p_access, "dvb-satno", &val );    if( val.i_int > 0 && val.i_int < 5 )    {        /* digital satellite equipment control,         * specification is available from http://www.eutelsat.com/         */        /* 1.x compatible equipment */        struct diseqc_cmd_t cmd =  { {{0xe0, 0x10, 0x38, 0xf0, 0x00, 0x00}, 4}, 0 };        /* param: high nibble: reset bits, low nibble set bits,         * bits are: option, position, polarization, band         */        cmd.cmd.msg[3] = 0xf0 /* reset bits */                          | (((val.i_int - 1) * 4) & 0xc)                          | (fe_voltage == SEC_VOLTAGE_13 ? 0 : 2)                          | (fe_tone == SEC_TONE_ON ? 1 : 0);        if( (i_err = ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_MASTER_CMD,                           &cmd.cmd )) < 0 )        {            msg_Err( p_access, "ioctl FE_SEND_MASTER_CMD failed (%d) %s",                     i_err, strerror(errno) );            return i_err;        }        msleep(15000 + cmd.wait * 1000);        /* A or B simple diseqc ("diseqc-compatible") */        if( (i_err = ioctl( p_sys->i_frontend_handle, FE_DISEQC_SEND_BURST,                      ((val.i_int - 1) % 2) ? SEC_MINI_B : SEC_MINI_A )) < 0 )        {            msg_Err( p_access, "ioctl FE_SEND_BURST failed (%d) %s",                     i_err, strerror(errno) );            return i_err;        }        msleep(15000);    }    if( (i_err = ioctl( p_sys->i_frontend_handle, FE_SET_TONE, fe_tone )) < 0 )    {        msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %s",                 fe_tone == SEC_TONE_ON ? "on" : "off", i_err,                 strerror(errno) );        return i_err;    }    msleep(50000);    return 0;}static int FrontendSetQPSK( access_t *p_access ){    access_sys_t *p_sys = p_access->p_sys;    struct dvb_frontend_parameters fep;    int i_ret;    vlc_value_t val;    int i_frequency, i_lnb_slof;    /* Prepare the fep structure */    var_Get( p_access, "dvb-frequency", &val );    i_frequency = val.i_int;    var_Get( p_access, "dvb-lnb-slof", &val );    i_lnb_slof = val.i_int;    if( i_frequency >= i_lnb_slof )        var_Get( p_access, "dvb-lnb-lof2", &val );    else        var_Get( p_access, "dvb-lnb-lof1", &val );    fep.frequency = i_frequency - val.i_int;    fep.inversion = DecodeInversion( p_access );    var_Get( p_access, "dvb-srate", &val );    fep.u.qpsk.symbol_rate = val.i_int;    var_Get( p_access, "dvb-fec", &val );    fep.u.qpsk.fec_inner = DecodeFEC( p_access, val.i_int );    if( DoDiseqc( p_access ) < 0 )    {        return VLC_EGENERIC;    }    /* Empty the event queue */    for( ; ; )    {        struct dvb_frontend_event event;        if ( ioctl( p_sys->i_frontend_handle, FE_GET_EVENT, &event ) < 0              && errno == EWOULDBLOCK )            break;    }    /* Now send it all to the frontend device */    if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )    {        msg_Err( p_access, "DVB-S: setting frontend failed (%d) %s", i_ret,                 strerror(errno) );        return VLC_EGENERIC;    }    return VLC_SUCCESS;}/***************************************************************************** * FrontendSetQAM : controls the FE device *****************************************************************************/static int FrontendSetQAM( access_t *p_access ){    access_sys_t *p_sys = p_access->p_sys;    struct dvb_frontend_parameters fep;    vlc_value_t val;    int i_ret;    /* Prepare the fep structure */    var_Get( p_access, "dvb-frequency", &val );    fep.frequency = val.i_int;    fep.inversion = DecodeInversion( p_access );    var_Get( p_access, "dvb-srate", &val );    fep.u.qam.symbol_rate = val.i_int;    var_Get( p_access, "dvb-fec", &val );    fep.u.qam.fec_inner = DecodeFEC( p_access, val.i_int );    fep.u.qam.modulation = DecodeModulation( p_access );    /* Empty the event queue */    for( ; ; )    {        struct dvb_frontend_event event;        if ( ioctl( p_sys->i_frontend_handle, FE_GET_EVENT, &event ) < 0              && errno == EWOULDBLOCK )            break;    }    /* Now send it all to the frontend device */    if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )    {        msg_Err( p_access, "DVB-C: setting frontend failed (%d) %s", i_ret,                 strerror(errno) );        return VLC_EGENERIC;    }    return VLC_SUCCESS;}/***************************************************************************** * FrontendSetOFDM : controls the FE device *****************************************************************************/static fe_bandwidth_t DecodeBandwidth( access_t *p_access ){    vlc_value_t         val;    fe_bandwidth_t      fe_bandwidth = 0;    var_Get( p_access, "dvb-bandwidth", &val );    msg_Dbg( p_access, "using bandwidth=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_bandwidth = BANDWIDTH_AUTO; break;        case 6: fe_bandwidth = BANDWIDTH_6_MHZ; break;        case 7: fe_bandwidth = BANDWIDTH_7_MHZ; break;        case 8: fe_bandwidth = BANDWIDTH_8_MHZ; break;        default:            msg_Dbg( p_access, "terrestrial dvb has bandwidth not set, using auto" );            fe_bandwidth = BANDWIDTH_AUTO;            break;    }    return fe_bandwidth;}static fe_transmit_mode_t DecodeTransmission( access_t *p_access ){    vlc_value_t         val;    fe_transmit_mode_t  fe_transmission = 0;    var_Get( p_access, "dvb-transmission", &val );    msg_Dbg( p_access, "using transmission=%d", val.i_int );    switch( val.i_int )    {        case 0: fe_transmission = TRANSMISSION_MODE_AUTO; break;        case 2: fe_transmission = TRANSMISSION_MODE_2K; break;        case 8: fe_transmission = TRANSMISSION_MODE_8K; break;        default:            msg_Dbg( p_access, "terrestrial dvb has transmission mode not set, using auto");            fe_transmission = TRANSMISSION_MODE_AUTO;            break;    }    return fe_transmission;}

⌨️ 快捷键说明

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