*****************************************************************************/
#include <vlc/vlc.h>
-#include <vlc/input.h>
-
+#include <vlc_access.h>
#include <sys/ioctl.h>
#include <errno.h>
static int FrontendSetQPSK( access_t * );
static int FrontendSetQAM( access_t * );
static int FrontendSetOFDM( access_t * );
+static int FrontendSetATSC( access_t * );
/*****************************************************************************
* FrontendOpen : Determine frontend device information and capabilities
msg_Dbg( p_access, "Opening device %s", frontend );
if( (p_sys->i_frontend_handle = open(frontend, O_RDWR | O_NONBLOCK)) < 0 )
{
- msg_Err( p_access, "FrontEndOpen: opening device failed (%s)",
- strerror(errno) );
+ msg_Err( p_access, "FrontEndOpen: opening device failed (%m)" );
free( p_frontend );
return VLC_EGENERIC;
}
if( b_probe )
{
- char * psz_expected = NULL;
- char * psz_real;
+ const char * psz_expected = NULL;
+ const char * psz_real;
if( FrontendInfo( p_access ) < 0 )
{
case FE_QPSK:
psz_real = "DVB-S";
break;
+ case FE_ATSC:
+ psz_real = "ATSC";
+ break;
default:
psz_real = "unknown";
}
psz_expected = "DVB-T";
}
+ if( (!strncmp( p_access->psz_access, "usdigital", 9 ) ||
+ !strncmp( p_access->psz_access, "atsc", 4 ) ) &&
+ (p_frontend->info.type != FE_ATSC) )
+ {
+ psz_expected = "ATSC";
+ }
+
if( psz_expected != NULL )
{
msg_Err( p_access, "the user asked for %s, and the tuner is %s",
else if( !strncmp( p_access->psz_access, "terrestrial", 11 ) ||
!strncmp( p_access->psz_access, "dvb-t", 5 ) )
p_frontend->info.type = FE_OFDM;
+ else if( !strncmp( p_access->psz_access, "usdigital", 9 ) ||
+ !strncmp( p_access->psz_access, "atsc", 4 ) )
+ p_frontend->info.type = FE_ATSC;
}
return VLC_SUCCESS;
}
break;
+ /* ATSC */
+ case FE_ATSC:
+ if( FrontendSetATSC( p_access ) < 0 )
+ {
+ msg_Err( p_access, "ATSC: tuning failed" );
+ return VLC_EGENERIC;
+ }
+ break;
+
default:
msg_Err( p_access, "Could not determine frontend type on %s",
p_sys->p_frontend->info.name );
if( errno == EWOULDBLOCK )
return; /* no more events */
- msg_Err( p_access, "reading frontend event failed (%d) %s",
- i_ret, strerror(errno) );
+ msg_Err( p_access, "reading frontend event failed (%d): %m",
+ i_ret );
return;
}
if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_GET_INFO,
&p_frontend->info )) < 0 )
{
- p += sprintf( p, "ioctl FE_GET_INFO failed (%d) %s\n", i_ret,
- strerror(errno) );
+ 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;
}
if( (i_ret = ioctl( p_sys->i_frontend_handle, FE_READ_STATUS, &i_status ))
< 0 )
{
- p += sprintf( p, "</table>ioctl FE_READ_STATUS failed (%d) %s\n", i_ret,
- strerror(errno) );
+ 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;
}
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) %s", i_ret,
- strerror(errno) );
+ msg_Err( p_access, "ioctl FE_GET_INFO failed (%d): %m", i_ret );
return VLC_EGENERIC;
}
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" );
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;
return fe_fec;
}
-static fe_modulation_t DecodeModulation( access_t *p_access )
+static fe_modulation_t DecodeModulationQAM( 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 )
+ switch( var_GetInteger( p_access, "dvb-modulation" ) )
{
- 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;
+ 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, "terrestrial/cable dvb has constellation/modulation not set, using auto");
- fe_modulation = QAM_AUTO;
- break;
+ 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;
}
- return fe_modulation;
}
/*****************************************************************************
/* 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) );
+ msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %m",
+ fe_tone == SEC_TONE_ON ? "on" : "off", i_err );
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) );
+ msg_Err( p_access, "ioctl FE_SET_VOLTAGE failed, voltage=%d (%d) %m",
+ fe_voltage, i_err );
return i_err;
}
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) );
+ "ioctl FE_ENABLE_HIGH_LNB_VOLTAGE failed, val=%d (%d) %m",
+ val.b_bool, i_err );
}
/* Wait for at least 15 ms. */
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) );
+ msg_Err( p_access, "ioctl FE_SEND_MASTER_CMD failed (%d) %m",
+ i_err );
return i_err;
}
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) );
+ msg_Err( p_access, "ioctl FE_SEND_BURST failed (%d) %m",
+ i_err );
return i_err;
}
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) );
+ msg_Err( p_access, "ioctl FE_SET_TONE failed, tone=%s (%d) %m",
+ fe_tone == SEC_TONE_ON ? "on" : "off", i_err );
return i_err;
}
/* 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) );
+ msg_Err( p_access, "DVB-S: setting frontend failed (%d) %m", i_ret );
return VLC_EGENERIC;
}
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 );
+ fep.u.qam.modulation = DecodeModulationQAM( p_access );
/* Empty the event queue */
for( ; ; )
/* 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) );
+ msg_Err( p_access, "DVB-C: setting frontend failed (%d): %m", i_ret );
return VLC_EGENERIC;
}
fep.u.ofdm.code_rate_HP = DecodeFEC( p_access, val.i_int );
var_Get( p_access, "dvb-code-rate-lp", &val );
fep.u.ofdm.code_rate_LP = DecodeFEC( p_access, val.i_int );
- fep.u.ofdm.constellation = DecodeModulation( p_access );
+ fep.u.ofdm.constellation = DecodeModulationOFDM( p_access );
fep.u.ofdm.transmission_mode = DecodeTransmission( p_access );
fep.u.ofdm.guard_interval = DecodeGuardInterval( p_access );
fep.u.ofdm.hierarchy_information = DecodeHierarchy( p_access );
/* Now send it all to the frontend device */
if( (ret = ioctl( p_sys->i_frontend_handle, FE_SET_FRONTEND, &fep )) < 0 )
{
- msg_Err( p_access, "DVB-T: setting frontend failed (%d) %s", ret,
- strerror(errno) );
+ msg_Err( p_access, "DVB-T: setting frontend failed (%d): %m", ret );
return -1;
}
return VLC_SUCCESS;
}
+/*****************************************************************************
+ * FrontendSetATSC : controls the FE device
+ *****************************************************************************/
+static int FrontendSetATSC( 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.u.vsb.modulation = DecodeModulationATSC( 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, "ATSC: setting frontend failed (%d): %m", i_ret );
+ return VLC_EGENERIC;
+ }
+
+ return VLC_SUCCESS;
+}
+
/*
* Demux
msg_Dbg( p_access, "Opening device %s", dmx );
if( (*pi_fd = open(dmx, O_RDWR)) < 0 )
{
- msg_Err( p_access, "DMXSetFilter: opening device failed (%s)",
- strerror(errno) );
+ msg_Err( p_access, "DMXSetFilter: opening device failed (%m)" );
return VLC_EGENERIC;
}
/* We then give the order to the device : */
if( (i_ret = ioctl( *pi_fd, DMX_SET_PES_FILTER, &s_filter_params )) < 0 )
{
- msg_Err( p_access, "DMXSetFilter: failed with %d (%s)", i_ret,
- strerror(errno) );
+ msg_Err( p_access, "DMXSetFilter: failed with %d (%m)", i_ret );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
if( (i_ret = ioctl( i_fd, DMX_STOP )) < 0 )
{
- msg_Err( p_access, "DMX_STOP failed for demux (%d) %s",
- i_ret, strerror(errno) );
+ msg_Err( p_access, "DMX_STOP failed for demux (%d): %m", i_ret );
return i_ret;
}
msg_Dbg( p_access, "Opening device %s", dvr );
if( (p_sys->i_handle = open(dvr, O_RDONLY)) < 0 )
{
- msg_Err( p_access, "DVROpen: opening device failed (%s)",
- strerror(errno) );
+ msg_Err( p_access, "DVROpen: opening device failed (%m)" );
return VLC_EGENERIC;
}
if( fcntl( p_sys->i_handle, F_SETFL, O_NONBLOCK ) == -1 )
{
- msg_Warn( p_access, "DVROpen: couldn't set non-blocking mode (%s)",
- strerror(errno) );
+ msg_Warn( p_access, "DVROpen: couldn't set non-blocking mode (%m)" );
}
return VLC_SUCCESS;
msg_Dbg( p_access, "Opening device %s", ca );
if( (p_sys->i_ca_handle = open(ca, O_RDWR | O_NONBLOCK)) < 0 )
{
- msg_Warn( p_access, "CAMInit: opening CAM device failed (%s)",
- strerror(errno) );
+ msg_Warn( p_access, "CAMInit: opening CAM device failed (%m)" );
p_sys->i_ca_handle = 0;
return VLC_EGENERIC;
}
}
/* Output CA capabilities */
- msg_Dbg( p_access, "CAMInit: CA interface with %d %s", caps.slot_num,
+ msg_Dbg( p_access, "CAMInit: CA interface with %d %s", caps.slot_num,
caps.slot_num == 1 ? "slot" : "slots" );
if ( caps.slot_type & CA_CI )
msg_Dbg( p_access, "CAMInit: CI high level interface type" );
if ( ioctl( p_sys->i_ca_handle, CA_GET_CAP, &caps ) != 0 )
{
- p += sprintf( p, "ioctl CA_GET_CAP failed (%s)\n",
- strerror(errno) );
+ char buf[1000];
+ strerror_r( errno, buf, sizeof( buf ) );
+ p += sprintf( p, "ioctl CA_GET_CAP failed (%s)\n", buf );
goto out;
}
sinfo.num = i_slot;
if ( ioctl( p_sys->i_ca_handle, CA_GET_SLOT_INFO, &sinfo ) != 0 )
{
- p += sprintf( p, "ioctl CA_GET_SLOT_INFO failed (%s)<br>\n",
- strerror(errno) );
+ char buf[1000];
+ strerror_r( errno, buf, sizeof( buf ) );
+ p += sprintf( p, "ioctl CA_GET_SLOT_INFO failed (%s)<br>\n", buf );
continue;
}
#define CHECK_TYPE( x, s ) \
if ( sinfo.type & (CA_##x) ) \
- p += sprintf( p, s );
+ p += sprintf( p, "%s", s );
CHECK_TYPE( CI, "high level, " );
CHECK_TYPE( CI_LINK, "link layer level, " );
{
access_sys_t *p_sys = p_access->p_sys;
- if ( p_sys->i_ca_handle == 0 )
+ if( p_sys->i_ca_handle == 0 )
{
+ dvbpsi_DeletePMT( p_pmt );
return VLC_EGENERIC;
}