[vlc-commits] DTV: add dvb_enum_systems() to list supported delivery systems

Rémi Denis-Courmont git at videolan.org
Tue Jul 12 17:14:39 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 12 17:38:56 2011 +0300| [dafa954d6cb79a21004f1507e8229789c35dc58d] | committer: Rémi Denis-Courmont

DTV: add dvb_enum_systems() to list supported delivery systems

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dafa954d6cb79a21004f1507e8229789c35dc58d
---

 modules/access/dtv/bdagraph.cpp |    5 ++++
 modules/access/dtv/dtv.h        |   12 +++++++++
 modules/access/dtv/linux.c      |   50 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/modules/access/dtv/bdagraph.cpp b/modules/access/dtv/bdagraph.cpp
index c27027e..e0f9d08 100644
--- a/modules/access/dtv/bdagraph.cpp
+++ b/modules/access/dtv/bdagraph.cpp
@@ -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;
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index de9dbd5..90fc237 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -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 *);
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index 8e84345..73e18bc 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -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)



More information about the vlc-commits mailing list