📄 linux_dvb.c
字号:
/***************************************************************************** * FrontendStatus : Read frontend status *****************************************************************************/void FrontendStatus( access_t *p_access ){ access_sys_t *p_sys = p_access->p_sys; frontend_t *p_frontend = p_sys->p_frontend; char *p = p_sys->psz_frontend_info = malloc( 10000 ); fe_status_t i_status; int i_ret; /* Determine type of frontend */ if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_GET_INFO, &p_frontend->info )) < 0 ) { char buf[1000]; strerror_r( errno, buf, sizeof( buf ) ); p += sprintf( p, "ioctl FE_GET_INFO failed (%d) %s\n", i_ret, buf ); goto out; } /* Print out frontend capabilities. */ p += sprintf( p, "<table border=1><tr><th>name</th><td>%s</td></tr>\n", p_frontend->info.name ); switch( p_frontend->info.type ) { case FE_QPSK: p += sprintf( p, "<tr><th>type</th><td>QPSK (DVB-S)</td></tr>\n" ); break; case FE_QAM: p += sprintf( p, "<tr><th>type</th><td>QAM (DVB-C)</td></tr>\n" ); break; case FE_OFDM: p += sprintf( p, "<tr><th>type</th><td>OFDM (DVB-T)</td></tr>\n" ); break;#if 0 /* DVB_API_VERSION == 3 */ case FE_MEMORY: p += sprintf( p, "<tr><th>type</th><td>MEMORY</td></tr>\n" ); break; case FE_NET: p += sprintf( p, "<tr><th>type</th><td>NETWORK</td></tr>\n" ); break;#endif default: p += sprintf( p, "<tr><th>type</th><td>UNKNOWN (%d)</td></tr>\n", p_frontend->info.type ); goto out; }#define CHECK_INFO( x ) \ p += sprintf( p, \ "<tr><th>" STRINGIFY(x) "</th><td>%u</td></tr>\n", \ p_frontend->info.x ); CHECK_INFO( frequency_min ); CHECK_INFO( frequency_max ); CHECK_INFO( frequency_stepsize ); CHECK_INFO( frequency_tolerance ); CHECK_INFO( symbol_rate_min ); CHECK_INFO( symbol_rate_max ); CHECK_INFO( symbol_rate_tolerance ); CHECK_INFO( notifier_delay );#undef CHECK_INFO p += sprintf( p, "</table><p>Frontend capability list:\n<table border=1>" );#define CHECK_CAPS( x ) \ if ( p_frontend->info.caps & (FE_##x) ) \ p += sprintf( p, "<tr><td>" STRINGIFY(x) "</td></tr>\n" ); CHECK_CAPS( IS_STUPID ); CHECK_CAPS( CAN_INVERSION_AUTO ); CHECK_CAPS( CAN_FEC_1_2 ); CHECK_CAPS( CAN_FEC_2_3 ); CHECK_CAPS( CAN_FEC_3_4 ); CHECK_CAPS( CAN_FEC_4_5 ); CHECK_CAPS( CAN_FEC_5_6 ); CHECK_CAPS( CAN_FEC_6_7 ); CHECK_CAPS( CAN_FEC_7_8 ); CHECK_CAPS( CAN_FEC_8_9 ); CHECK_CAPS( CAN_FEC_AUTO ); CHECK_CAPS( CAN_QPSK ); CHECK_CAPS( CAN_QAM_16 ); CHECK_CAPS( CAN_QAM_32 ); CHECK_CAPS( CAN_QAM_64 ); CHECK_CAPS( CAN_QAM_128 ); CHECK_CAPS( CAN_QAM_256 ); CHECK_CAPS( CAN_QAM_AUTO ); CHECK_CAPS( CAN_TRANSMISSION_MODE_AUTO ); CHECK_CAPS( CAN_BANDWIDTH_AUTO ); CHECK_CAPS( CAN_GUARD_INTERVAL_AUTO ); CHECK_CAPS( CAN_HIERARCHY_AUTO ); CHECK_CAPS( CAN_MUTE_TS ); CHECK_CAPS( CAN_RECOVER );#if 0 /* Disabled because of older distributions */ CHECK_CAPS( CAN_CLEAN_SETUP );#endif#undef CHECK_CAPS p += sprintf( p, "</table><p>Current frontend status:\n<table border=1>" ); if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_READ_STATUS, &i_status )) < 0 ) { char buf[1000]; strerror_r( errno, buf, sizeof( buf ) ); p += sprintf( p, "</table>ioctl FE_READ_STATUS failed (%d) %s\n", i_ret, buf ); goto out; }#define CHECK_STATUS( x ) \ if ( i_status & (FE_##x) ) \ p += sprintf( p, "<tr><td>" STRINGIFY(x) "</td></tr>\n" ); CHECK_STATUS( HAS_SIGNAL ); CHECK_STATUS( HAS_CARRIER ); CHECK_STATUS( HAS_VITERBI ); CHECK_STATUS( HAS_SYNC ); CHECK_STATUS( HAS_LOCK ); CHECK_STATUS( REINIT ); if( i_status == 0 ) p += sprintf( p, "<tr><td>Tuning failed</td></tr>\n" );#undef CHECK_STATUS if ( i_status & FE_HAS_LOCK ) { int32_t i_value; p += sprintf( p, "</table><p>Signal status:\n<table border=1>" ); if( ioctl( p_sys->i_frontend_handle, FE_READ_BER, &i_value ) >= 0 ) p += sprintf( p, "<tr><th>Bit error rate</th><td>%d</td></tr>\n", i_value ); if( ioctl( p_sys->i_frontend_handle, FE_READ_SIGNAL_STRENGTH, &i_value ) >= 0 ) p += sprintf( p, "<tr><th>Signal strength</th><td>%d</td></tr>\n", i_value ); if( ioctl( p_sys->i_frontend_handle, FE_READ_SNR, &i_value ) >= 0 ) p += sprintf( p, "<tr><th>SNR</th><td>%d</td></tr>\n", i_value ); } p += sprintf( p, "</table>" );out: vlc_mutex_lock( &p_sys->httpd_mutex ); p_sys->b_request_frontend_info = false; vlc_cond_signal( &p_sys->httpd_cond ); vlc_mutex_unlock( &p_sys->httpd_mutex );}#endif/***************************************************************************** * FrontendInfo : Return information about given frontend *****************************************************************************/static int FrontendInfo( access_t *p_access ){ access_sys_t *p_sys = p_access->p_sys; frontend_t *p_frontend = p_sys->p_frontend; int i_ret; /* Determine type of frontend */ if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_GET_INFO, &p_frontend->info )) < 0 ) { msg_Err( p_access, "ioctl FE_GET_INFO failed (%d): %m", i_ret ); return VLC_EGENERIC; } /* Print out frontend capabilities. */ msg_Dbg(p_access, "Frontend Info:" ); msg_Dbg(p_access, " name = %s", p_frontend->info.name ); switch( p_frontend->info.type ) { case FE_QPSK: msg_Dbg( p_access, " type = QPSK (DVB-S)" ); break; case FE_QAM: msg_Dbg( p_access, " type = QAM (DVB-C)" ); break; case FE_OFDM: msg_Dbg( p_access, " type = OFDM (DVB-T)" ); break; case FE_ATSC: msg_Dbg( p_access, " type = ATSC (USA)" ); break;#if 0 /* DVB_API_VERSION == 3 */ case FE_MEMORY: msg_Dbg(p_access, " type = MEMORY" ); break; case FE_NET: msg_Dbg(p_access, " type = NETWORK" ); break;#endif default: msg_Err( p_access, " unknown frontend type (%d)", p_frontend->info.type ); return VLC_EGENERIC; } msg_Dbg(p_access, " frequency_min = %u (kHz)", p_frontend->info.frequency_min); msg_Dbg(p_access, " frequency_max = %u (kHz)", p_frontend->info.frequency_max); msg_Dbg(p_access, " frequency_stepsize = %u", p_frontend->info.frequency_stepsize); msg_Dbg(p_access, " frequency_tolerance = %u", p_frontend->info.frequency_tolerance); msg_Dbg(p_access, " symbol_rate_min = %u (kHz)", p_frontend->info.symbol_rate_min); msg_Dbg(p_access, " symbol_rate_max = %u (kHz)", p_frontend->info.symbol_rate_max); msg_Dbg(p_access, " symbol_rate_tolerance (ppm) = %u", p_frontend->info.symbol_rate_tolerance); msg_Dbg(p_access, " notifier_delay (ms) = %u", p_frontend->info.notifier_delay ); msg_Dbg(p_access, "Frontend Info capability list:"); if( p_frontend->info.caps & FE_IS_STUPID) msg_Dbg(p_access, " no capabilities - frontend is stupid!"); if( p_frontend->info.caps & FE_CAN_INVERSION_AUTO) msg_Dbg(p_access, " inversion auto"); if( p_frontend->info.caps & FE_CAN_FEC_1_2) msg_Dbg(p_access, " forward error correction 1/2"); if( p_frontend->info.caps & FE_CAN_FEC_2_3) msg_Dbg(p_access, " forward error correction 2/3"); if( p_frontend->info.caps & FE_CAN_FEC_3_4) msg_Dbg(p_access, " forward error correction 3/4"); if( p_frontend->info.caps & FE_CAN_FEC_4_5) msg_Dbg(p_access, " forward error correction 4/5"); if( p_frontend->info.caps & FE_CAN_FEC_5_6) msg_Dbg(p_access, " forward error correction 5/6"); if( p_frontend->info.caps & FE_CAN_FEC_6_7) 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"); if( p_frontend->info.caps & FE_CAN_8VSB) msg_Dbg(p_access, " card can do 8vsb"); if( p_frontend->info.caps & FE_CAN_16VSB) msg_Dbg(p_access, " card can do 16vsb"); 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 DecodeModulationQAM( access_t *p_access ){ switch( var_GetInteger( p_access, "dvb-modulation" ) ) { case 0: return QAM_AUTO; case 16: return QAM_16; case 32: return QAM_32; case 64: return QAM_64; case 128: return QAM_128; case 256: return QAM_256; default: msg_Dbg( p_access, "QAM modulation not set, using auto"); return QAM_AUTO; }}static fe_modulation_t DecodeModulationOFDM( access_t *p_access ){ switch( var_GetInteger( p_access, "dvb-modulation" ) ) { case -1: return QPSK; case 0: return QAM_AUTO; case 16: return QAM_16; case 32: return QAM_32; case 64: return QAM_64; case 128: return QAM_128; case 256: return QAM_256; default: msg_Dbg( p_access, "OFDM modulation not set, using QAM auto"); return QAM_AUTO; }}static fe_modulation_t DecodeModulationATSC( access_t *p_access ){ switch( var_GetInteger( p_access, "dvb-modulation" ) ) { case 8: return VSB_8; case 16: return VSB_16; default: msg_Dbg( p_access, "ATSC modulation not set, using VSB 8"); return VSB_8; }}/***************************************************************************** * FrontendSetQPSK : controls the FE device *****************************************************************************/static fe_sec_voltage_t DecodeVoltage( access_t *p_access ){ vlc_value_t val;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -