]> git.sesse.net Git - vlc/blobdiff - modules/access/dtv/linux.c
Revert "Add an automate variable to detect Android builb and use it to forbid build of"
[vlc] / modules / access / dtv / linux.c
index 65cad0ae519c9737bfb7dc70c21e8cc13c39a0e5..16fbd1e82d18c65e18f8b9b8bf4bcb3fa203fc04 100644 (file)
@@ -32,6 +32,7 @@
 #include <poll.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <linux/dvb/version.h>
 #include <linux/dvb/frontend.h>
 #include <linux/dvb/dmx.h>
 
 # define O_SEARCH O_RDONLY
 #endif
 
+#define DVBv5(minor) \
+        (DVB_API_VERSION > 5 \
+     || (DVB_API_VERSION == 5 && DVB_API_VERSION_MINOR >= (minor)))
+#if !DVBv5(0)
+# error Linux DVB kernel headers version 2.6.28 or later required.
+#endif
+
 /** Opens the device directory for the specified DVB adapter */
 static int dvb_open_adapter (uint8_t adapter)
 {
@@ -132,24 +140,26 @@ static int dvb_parse_modulation (const char *str, int def)
     return dvb_parse_str (str, mods, sizeof (mods) / sizeof (*mods), def);
 }
 
-static int dvb_parse_fec (const char *str)
+static int dvb_parse_fec (uint32_t fec)
 {
-    static const dvb_str_map_t rates[] =
+    static const dvb_int_map_t rates[] =
     {
-        { "",     FEC_AUTO },
-        { "1/2",  FEC_1_2  },
+        { 0,             FEC_NONE },
+        { VLC_FEC(1,2),  FEC_1_2  },
         // TODO: 1/3
         // TODO: 1/4
-        { "2/3",  FEC_2_3  },
-        { "3/4",  FEC_3_4  },
-        { "4/5",  FEC_4_5  },
-        { "5/6",  FEC_5_6  },
-        { "6/7",  FEC_6_7  },
-        { "7/8",  FEC_7_8  },
-        { "8/9",  FEC_8_9  },
-        { "9/10", FEC_9_10 },
+        { VLC_FEC(2,3),  FEC_2_3  },
+        { VLC_FEC(3,4),  FEC_3_4  },
+        { VLC_FEC(3,5),  FEC_3_5  },
+        { VLC_FEC(4,5),  FEC_4_5  },
+        { VLC_FEC(5,6),  FEC_5_6  },
+        { VLC_FEC(6,7),  FEC_6_7  },
+        { VLC_FEC(7,8),  FEC_7_8  },
+        { VLC_FEC(8,9),  FEC_8_9  },
+        { VLC_FEC(9,10), FEC_9_10 },
+        { VLC_FEC_AUTO,  FEC_AUTO },
     };
-    return dvb_parse_str (str, rates, sizeof (rates) / sizeof (*rates),
+    return dvb_parse_int (fec, rates, sizeof (rates) / sizeof (*rates),
                           FEC_AUTO);
 }
 
@@ -271,6 +281,14 @@ dvb_device_t *dvb_open (vlc_object_t *obj, bool tune)
         msg_Dbg (obj, "using frontend: %s", d->info.name);
         msg_Dbg (obj, " type %u, capabilities 0x%08X", d->info.type,
                  d->info.caps);
+        msg_Dbg (obj, " frequencies %10"PRIu32" to %10"PRIu32,
+                 d->info.frequency_min, d->info.frequency_max);
+        msg_Dbg (obj, " (%"PRIu32" tolerance, %"PRIu32" per step)",
+                 d->info.frequency_tolerance, d->info.frequency_stepsize);
+        msg_Dbg (obj, " bauds rates %10"PRIu32" to %10"PRIu32,
+                 d->info.symbol_rate_min, d->info.symbol_rate_max);
+        msg_Dbg (obj, " (%"PRIu32" tolerance)",
+                 d->info.symbol_rate_tolerance);
 
         d->ca = dvb_open_node (dirfd, device, "ca", O_RDWR);
         if (d->ca == -1)
@@ -523,10 +541,10 @@ int dvb_tune (dvb_device_t *d)
 
 /*** DVB-C ***/
 int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr,
-                  uint32_t srate, const char *fecstr)
+                  uint32_t srate, uint32_t fec)
 {
     unsigned mod = dvb_parse_modulation (modstr, QAM_AUTO);
-    unsigned fec = dvb_parse_fec (fecstr);
+    fec = dvb_parse_fec (fec);
 
     return dvb_set_props (d, 6, DTV_CLEAR, 0,
                           DTV_DELIVERY_SYSTEM, SYS_DVBC_ANNEX_AC,
@@ -647,10 +665,9 @@ known:
     return dvb_set_props (d, 2, DTV_FREQUENCY, freq, DTV_TONE, tone);
 }
 
-int dvb_set_dvbs (dvb_device_t *d, uint32_t freq,
-                  uint32_t srate, const char *fecstr)
+int dvb_set_dvbs (dvb_device_t *d, uint32_t freq, uint32_t srate, uint32_t fec)
 {
-    unsigned fec = dvb_parse_fec (fecstr);
+    fec = dvb_parse_fec (fec);
 
     return dvb_set_props (d, 5, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBS,
                           DTV_FREQUENCY, freq, DTV_SYMBOL_RATE, srate,
@@ -658,10 +675,10 @@ int dvb_set_dvbs (dvb_device_t *d, uint32_t freq,
 }
 
 int dvb_set_dvbs2 (dvb_device_t *d, uint32_t freq, const char *modstr,
-                   uint32_t srate, const char *fecstr, int pilot, int rolloff)
+                   uint32_t srate, uint32_t fec, int pilot, int rolloff)
 {
     unsigned mod = dvb_parse_modulation (modstr, QPSK);
-    unsigned fec = dvb_parse_fec (fecstr);
+    fec = dvb_parse_fec (fec);
 
     switch (pilot)
     {
@@ -691,7 +708,9 @@ static int dvb_parse_transmit_mode (int i)
     static const dvb_int_map_t tab[] = {
         { -1, TRANSMISSION_MODE_AUTO },
         {  2, TRANSMISSION_MODE_2K   },
+#if DVBv5(1)
         {  4, TRANSMISSION_MODE_4K   },
+#endif
         {  8, TRANSMISSION_MODE_8K   },
 #if 0
         { 16, TRANSMISSION_MODE_16K  },
@@ -702,19 +721,19 @@ static int dvb_parse_transmit_mode (int i)
                           TRANSMISSION_MODE_AUTO);
 }
 
-static int dvb_parse_guard (const char *str)
+static int dvb_parse_guard (uint32_t guard)
 {
-    static const dvb_str_map_t tab[] = {
-        { "",       GUARD_INTERVAL_AUTO },
-      /*{ "1/128",  GUARD_INTERVAL_1_128 },*/
-        { "1/16",   GUARD_INTERVAL_1_16 },
-        { "1/32",   GUARD_INTERVAL_1_32 },
-        { "1/4",    GUARD_INTERVAL_1_4 },
-        { "1/8",    GUARD_INTERVAL_1_8 },
-      /*{ "19/128", GUARD_INTERVAL_19_128 },*/
-      /*{ "9/256",  GUARD_INTERVAL_9_256 },*/
+    static const dvb_int_map_t tab[] = {
+      /*{ VLC_GUARD(1,128),  GUARD_INTERVAL_1_128 },*/
+        { VLC_GUARD(1,16),   GUARD_INTERVAL_1_16 },
+        { VLC_GUARD(1,32),   GUARD_INTERVAL_1_32 },
+        { VLC_GUARD(1,4),    GUARD_INTERVAL_1_4 },
+        { VLC_GUARD(1,8),    GUARD_INTERVAL_1_8 },
+      /*{ VLC_GUARD(19,128), GUARD_INTERVAL_19_128 },*/
+      /*{ VLC_GUARD(9,256),  GUARD_INTERVAL_9_256 },*/
+        { VLC_GUARD_AUTO,    GUARD_INTERVAL_AUTO },
     };
-    return dvb_parse_str (str, tab, sizeof (tab) / sizeof (*tab),
+    return dvb_parse_int (guard, tab, sizeof (tab) / sizeof (*tab),
                           GUARD_INTERVAL_AUTO);
 }
 
@@ -732,23 +751,23 @@ static int dvb_parse_hierarchy (int i)
 }
 
 int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr,
-                  const char *fechstr, const char *feclstr, uint32_t bandwidth,
-                  int transmit_val, const char *guardstr, int hierarchy_val)
+                  uint32_t fec_hp, uint32_t fec_lp, uint32_t bandwidth,
+                  int transmit_mode, uint32_t guard, int hierarchy)
 {
     uint32_t mod = dvb_parse_modulation (modstr, QAM_AUTO);
-    uint32_t fec_hp = dvb_parse_fec (fechstr);
-    uint32_t fec_lp = dvb_parse_fec (feclstr);
+    fec_hp = dvb_parse_fec (fec_hp);
+    fec_lp = dvb_parse_fec (fec_lp);
     bandwidth *= 1000000;
-    uint32_t transmit_mode = dvb_parse_transmit_mode (transmit_val);
-    uint32_t guard_it = dvb_parse_guard (guardstr);
-    uint32_t hierarchy = dvb_parse_hierarchy (hierarchy_val);
+    transmit_mode = dvb_parse_transmit_mode (transmit_mode);
+    guard = dvb_parse_guard (guard);
+    hierarchy = dvb_parse_hierarchy (hierarchy);
 
     return dvb_set_props (d, 10, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBT,
                           DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod,
                           DTV_CODE_RATE_HP, fec_hp, DTV_CODE_RATE_LP, fec_lp,
                           DTV_BANDWIDTH_HZ, bandwidth,
                           DTV_TRANSMISSION_MODE, transmit_mode,
-                          DTV_GUARD_INTERVAL, guard_it,
+                          DTV_GUARD_INTERVAL, guard,
                           DTV_HIERARCHY, hierarchy);
 }