Commit dafa954d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

DTV: add dvb_enum_systems() to list supported delivery systems

parent bfb235db
......@@ -164,6 +164,11 @@ void dvb_remove_pid (dvb_device_t *, uint16_t)
{
}
unsigned dvb_enum_systems (dvb_device_t *)
{
#warning TODO
}
const delsys_t *dvb_guess_system (dvb_device_t *)
{
return NULL;
......
......@@ -26,6 +26,17 @@
extern "C" {
# endif
enum {
ATSC = 0x00000001,
DVB_C = 0x00000010,
DVB_C2 = 0x00000020,
DVB_S = 0x00000040,
DVB_S2 = 0x00000080,
DVB_T = 0x00000100,
DVB_T2 = 0x00000200,
};
typedef struct delsys delsys_t;
extern const delsys_t dvbc, dvbs, dvbs2, dvbt, dvbt2, atsc, cqam;
......@@ -39,6 +50,7 @@ ssize_t dvb_read (dvb_device_t *, void *, size_t);
int dvb_add_pid (dvb_device_t *, uint16_t);
void dvb_remove_pid (dvb_device_t *, uint16_t);
unsigned dvb_enum_systems (dvb_device_t *);
const delsys_t *dvb_guess_system (dvb_device_t *);
float dvb_get_signal_strength (dvb_device_t *);
float dvb_get_snr (dvb_device_t *);
......
......@@ -489,6 +489,56 @@ static int dvb_find_frontend (dvb_device_t *d, fe_type_t type, fe_caps_t caps)
return -1;
}
/**
* Detects supported delivery systems.
* @return a bit mask of supported systems (zero on failure)
*/
unsigned dvb_enum_systems (dvb_device_t *d)
{
unsigned systems = 0;
for (unsigned n = 0; n < 256; n++)
{
int fd = dvb_open_node (d->dir, "frontend", n, O_RDWR);
if (fd == -1)
{
if (errno == ENOENT)
break; /* all frontends already enumerated */
msg_Err (d->obj, "cannot access frontend %u; %m", n);
continue;
}
struct dvb_frontend_info info;
if (ioctl (fd, FE_GET_INFO, &info) < 0)
{
msg_Err (d->obj, "cannot get frontend %u info: %m", n);
close (fd);
continue;
}
close (fd);
/* Linux DVB lacks detection for non-DVB/non-ATSC demods */
static const unsigned types[] = {
[FE_QPSK] = DVB_S,
[FE_QAM] = DVB_C,
[FE_OFDM] = DVB_T,
[FE_ATSC] = ATSC,
};
if (((unsigned)info.type) >= sizeof (types) / sizeof (types[0]))
{
msg_Err (d->obj, "unknown frontend type %u", info.type);
continue;
}
unsigned sys = types[info.type];
if (info.caps & FE_CAN_2G_MODULATION)
sys |= sys << 1; /* DVB_foo -> DVB_foo|DVB_foo2 */
systems |= sys;
}
return systems;
}
const delsys_t *dvb_guess_system (dvb_device_t *d)
{
if (d->frontend == -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment