]> git.sesse.net Git - vlc/blobdiff - modules/access/dtv/access.c
DTV: deal with "cable", "terrestrial" and "satellite" scheme right
[vlc] / modules / access / dtv / access.c
index 142e51953e8f640abdaf3229a285f498e78088a4..c7cbf067698028a6ef8014c45181d6587ce6f253 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <vlc_common.h>
 #include <vlc_access.h>
+#include <vlc_input.h>
 #include <vlc_plugin.h>
 #include <vlc_dialog.h>
 #include <search.h>
@@ -229,14 +230,10 @@ vlc_module_begin ()
     set_capability ("access", 0)
     set_callbacks (Open, Close)
     add_shortcut ("dtv", "tv", "dvb", /* "radio", "dab",*/
-                  "cable", "dvb-c", "cqam"
+                  "cable", "dvb-c", "cqam", "isdb-c",
                   "satellite", "dvb-s", "dvb-s2", "isdb-s",
-                  "terrestrial", "dvb-t", "dvb-t2", "isdb-t", "atsc")
-
-    /* All options starting with dvb- can be overridden in the MRL, so they
-     * must all be "safe". Nevertheless, we do not mark as safe those that are
-     * really specific to the local system (e.g. device ID...).
-     * It wouldn't make sense to deliver those through a playlist. */
+                  "terrestrial", "dvb-t", "dvb-t2", "isdb-t", "atsc",
+                  "dvbt")
 
 #ifdef __linux__
     add_integer ("dvb-adapter", 0, ADAPTER_TEXT, ADAPTER_LONGTEXT, false)
@@ -366,14 +363,14 @@ vlc_module_begin ()
 #endif
     add_integer ("dvb-lnb-low", 0, LNB_LOW_TEXT, LNB_LONGTEXT, true)
         change_integer_range (0, 0x7fffffff)
-    add_obsolete_integer ("dvb-lnb-lof1") /* since 1.2.0 */
+    add_obsolete_integer ("dvb-lnb-lof1") /* since 2.0.0 */
     add_integer ("dvb-lnb-high", 0, LNB_HIGH_TEXT, LNB_LONGTEXT, true)
         change_integer_range (0, 0x7fffffff)
-    add_obsolete_integer ("dvb-lnb-lof2") /* since 1.2.0 */
+    add_obsolete_integer ("dvb-lnb-lof2") /* since 2.0.0 */
     add_integer ("dvb-lnb-switch", 11700000,
                  LNB_SWITCH_TEXT, LNB_SWITCH_LONGTEXT, true)
         change_integer_range (0, 0x7fffffff)
-    add_obsolete_integer ("dvb-lnb-slof") /* since 1.2.0 */
+    add_obsolete_integer ("dvb-lnb-slof") /* since 2.0.0 */
 #ifdef __linux__
     add_integer ("dvb-satno", 0, SATNO_TEXT, SATNO_LONGTEXT, true)
         change_integer_list (satno_vlc, satno_user)
@@ -399,6 +396,7 @@ vlc_module_end ()
 struct access_sys_t
 {
     dvb_device_t *dev;
+    uint8_t signal_poll;
 };
 
 typedef struct delsys
@@ -408,7 +406,7 @@ typedef struct delsys
 } delsys_t;
 
 static const delsys_t dvbc, dvbs, dvbs2, dvbt, dvbt2;
-static const delsys_t isdbs, isdbt;
+static const delsys_t isdbc, isdbs, isdbt;
 static const delsys_t atsc, cqam;
 
 static block_t *Read (access_t *);
@@ -434,6 +432,7 @@ static int Open (vlc_object_t *obj)
     }
 
     sys->dev = dev;
+    sys->signal_poll = 0;
     access->p_sys = sys;
 
     uint64_t freq = var_InheritFrequency (obj);
@@ -495,6 +494,12 @@ static block_t *Read (access_t *access)
     }
 
     block->i_buffer = val;
+
+    /* Fetch the signal levels every so often. Some devices do not like this
+     * to be requested too frequently, e.g. due to low bandwidth I²C bus. */
+    if ((sys->signal_poll++) == 0)
+        access->info.i_update |= INPUT_UPDATE_SIGNAL;
+
     return block;
 }
 
@@ -584,25 +589,7 @@ static int Control (access_t *access, int query, va_list args)
 /** Determines which delivery system to use. */
 static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev)
 {
-    /* NOTE: We should guess the delivery system for the "cable", "satellite"
-     * and "terrestrial" shortcuts (i.e. DVB, ISDB, ATSC...). But there is
-     * seemingly no sane way to do get the info with Linux DVB version 5.2.
-     * In particular, the frontend infos distinguish only the modulator class
-     * (QPSK, QAM, OFDM or ATSC).
-     *
-     * Furthermore, if the demodulator supports 2G, we cannot guess whether
-     * 1G or 2G is intended. For backward compatibility, 1G is assumed
-     * (this is not a limitation of Linux DVB). We will probably need something
-     * smarter when 2G (semi automatic) scanning is implemented. */
-    if (!strcasecmp (scheme, "cable"))
-        scheme = "dvb-c";
-    else
-    if (!strcasecmp (scheme, "satellite"))
-        scheme = "dvb-s";
-    else
-    if (!strcasecmp (scheme, "terrestrial"))
-        scheme = "dvb-t";
-
+    /* Specific delivery system is specified */
     if (!strcasecmp (scheme, "atsc"))
         return &atsc;
     if (!strcasecmp (scheme, "cqam"))
@@ -617,20 +604,55 @@ static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev)
         return &dvbt;
     if (!strcasecmp (scheme, "dvb-t2"))
         return &dvbt2;
+    if (!strcasecmp (scheme, "isdb-c"))
+        return &isdbc;
     if (!strcasecmp (scheme, "isdb-s"))
         return &isdbs;
     if (!strcasecmp (scheme, "isdb-t"))
         return &isdbt;
 
+    /* If the demodulator supports 2G, we cannot guess whether
+     * 1G or 2G is intended. For backward compatibility, 1G is assumed
+     * (this is not a limitation of Linux DVB). We will probably need something
+     * smarter when 2G (semi automatic) scanning is implemented. */
     unsigned systems = dvb_enum_systems (dev);
-    if (systems & ATSC)
-        return &atsc;
+
+    /* Only wave carrier is specified */
+    if (!strcasecmp (scheme, "cable"))
+    {
+        if (systems & DVB_C)
+            return &dvbc;
+        if (systems & CQAM)
+            return &cqam;
+        if (systems & ISDB_C)
+            return &isdbc;
+    }
+    if (!strcasecmp (scheme, "satellite"))
+    {
+        if (systems & DVB_S)
+            return &dvbs;
+        if (systems & ISDB_S)
+            return &isdbs;
+    }
+    if (!strcasecmp (scheme, "terrestrial"))
+    {
+        if (systems & DVB_T)
+            return &dvbc;
+        if (systems & ATSC)
+            return &cqam;
+        if (systems & ISDB_T)
+            return &isdbt;
+    }
+
+    /* Only standards family or nothing is specified */
     if (systems & DVB_C)
         return &dvbc;
     if (systems & DVB_S)
         return &dvbc;
     if (systems & DVB_T)
         return &dvbt;
+    if (systems & ATSC)
+        return &atsc;
     return NULL;
 }
 
@@ -882,6 +904,19 @@ static const delsys_t dvbt = { .setup = dvbt_setup };
 static const delsys_t dvbt2 = { .setup = dvbt2_setup };
 
 
+/*** ISDB-C ***/
+static int isdbc_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
+{
+    const char *mod = var_InheritModulation (obj, "dvb-modulation");
+    uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
+    unsigned srate = var_InheritInteger (obj, "dvb-srate");
+
+    return dvb_set_isdbc (dev, freq, mod, srate, fec);
+}
+
+static const delsys_t isdbc = { .setup = isdbc_setup };
+
+
 /*** ISDB-S ***/
 static int isdbs_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
 {