[vlc-commits] DTV: revert to Hertz instead of kilohertz unit (fixes #4981)

Rémi Denis-Courmont git at videolan.org
Sun Jun 26 16:49:54 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jun 26 17:46:43 2011 +0300| [ef0e4ce47cd105f83ebc060df1baeaba7a4cc700] | committer: Rémi Denis-Courmont

DTV: revert to Hertz instead of kilohertz unit (fixes #4981)

At least the ISDB-T standard export version uses sub-kHz precision
(never mind that one band occupies several megahertz in width).

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

 modules/access/dtv/access.c     |   24 ++++++++++++------------
 modules/access/dtv/bdagraph.cpp |   18 +++++++++---------
 modules/access/dtv/dtv.h        |    6 +++---
 modules/access/dtv/linux.c      |   17 +++++++++++------
 4 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/modules/access/dtv/access.c b/modules/access/dtv/access.c
index 90c3d9e..428010f 100644
--- a/modules/access/dtv/access.c
+++ b/modules/access/dtv/access.c
@@ -52,7 +52,7 @@
 #define CREATE_TEXT N_("Network name to create")
 #define CREATE_LONGTEXT N_("Create unique name in the System Tuning Spaces")
 
-#define FREQ_TEXT N_("Frequency (kHz)")
+#define FREQ_TEXT N_("Frequency (Hz)")
 #define FREQ_LONGTEXT N_( \
     "TV channels are grouped by transponder (a.k.a. multiplex) " \
     "on a given frequency. This is required to tune the receiver.")
@@ -350,8 +350,8 @@ struct delsys
 static block_t *Read (access_t *);
 static int Control (access_t *, int, va_list);
 static const delsys_t *GuessSystem (const char *, dvb_device_t *);
-static int Tune (vlc_object_t *, dvb_device_t *, const delsys_t *, unsigned);
-static unsigned var_InheritFrequency (vlc_object_t *);
+static int Tune (vlc_object_t *, dvb_device_t *, const delsys_t *, uint64_t);
+static uint64_t var_InheritFrequency (vlc_object_t *);
 
 static int Open (vlc_object_t *obj)
 {
@@ -372,13 +372,13 @@ static int Open (vlc_object_t *obj)
     sys->dev = dev;
     access->p_sys = sys;
 
-    unsigned freq = var_InheritFrequency (obj);
+    uint64_t freq = var_InheritFrequency (obj);
     if (freq != 0)
     {
         const delsys_t *delsys = GuessSystem (access->psz_access, dev);
         if (delsys == NULL || Tune (obj, dev, delsys, freq))
         {
-            msg_Err (obj, "tuning to %u kHz failed", freq);
+            msg_Err (obj, "tuning to %"PRIu64" Hz failed", freq);
             dialog_Fatal (obj, N_("Digital broadcasting"),
                           N_("The selected digital tuner does not support "
                              "the specified parameters.\n"
@@ -559,7 +559,7 @@ static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev)
 
 /** Set parameters and tune the device */
 static int Tune (vlc_object_t *obj, dvb_device_t *dev, const delsys_t *delsys,
-                 unsigned freq)
+                 uint64_t freq)
 {
     if (delsys->setup (obj, dev, freq)
      || dvb_set_inversion (dev, var_InheritInteger (obj, "dvb-inversion"))
@@ -568,14 +568,14 @@ static int Tune (vlc_object_t *obj, dvb_device_t *dev, const delsys_t *delsys,
     return VLC_SUCCESS;
 }
 
-static unsigned var_InheritFrequency (vlc_object_t *obj)
+static uint64_t var_InheritFrequency (vlc_object_t *obj)
 {
-    unsigned freq = var_InheritInteger (obj, "dvb-frequency");
-    if (freq >= 108000000)
+    uint64_t freq = var_InheritInteger (obj, "dvb-frequency");
+    if (freq <= 108000000)
     {
-        msg_Err (obj, "%u kHz frequency is too high.", freq);
-        freq /= 1000;
-        msg_Info (obj, "Assuming %u kHz carrier frequency instead.", freq);
+        msg_Err (obj, "%"PRIu64" Hz carrier frequency is too low.", freq);
+        freq *= 1000;
+        msg_Info (obj, "Assuming %"PRIu64" Hz frequency instead.", freq);
     }
     return freq;
 }
diff --git a/modules/access/dtv/bdagraph.cpp b/modules/access/dtv/bdagraph.cpp
index 3a156bf..c27027e 100644
--- a/modules/access/dtv/bdagraph.cpp
+++ b/modules/access/dtv/bdagraph.cpp
@@ -197,29 +197,29 @@ int dvb_tune (dvb_device_t *d)
 int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *mod,
                   uint32_t srate, uint32_t /*fec*/)
 {
-    return d->module->SetDVBC (freq, mod, srate);
+    return d->module->SetDVBC (freq / 1000, mod, srate);
 }
 
 /* DVB-S */
-int dvb_set_dvbs (dvb_device_t *d, uint32_t freq, uint32_t srate, uint32_t fec)
+int dvb_set_dvbs (dvb_device_t *d, uint64_t freq, uint32_t srate, uint32_t fec)
 {
-    d->frequency = freq;
+    d->frequency = freq / 1000;
     d->srate = srate;
     d->fec = fec;
     return d->module->SetDVBS(d->frequency, d->srate, d->fec, d->inversion,
                               d->pol, d->lowf, d->highf, d->switchf);
 }
 
-int dvb_set_dvbs2 (dvb_device_t *, uint32_t /*freq*/, const char * /*mod*/,
+int dvb_set_dvbs2 (dvb_device_t *, uint64_t /*freq*/, const char * /*mod*/,
                    uint32_t /*srate*/, uint32_t /*fec*/, int /*pilot*/, int /*rolloff*/)
 {
     return VLC_EGENERIC;
 }
 
-int dvb_set_sec (dvb_device_t *d, uint32_t freq, char pol,
+int dvb_set_sec (dvb_device_t *d, uint64_t freq, char pol,
                  uint32_t lowf, uint32_t highf, uint32_t switchf)
 {
-    d->frequency = freq;
+    d->frequency = freq / 1000;
     d->pol = pol;
     d->lowf = lowf;
     d->highf = highf;
@@ -233,7 +233,7 @@ int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char * /*mod*/,
                   uint32_t fec_hp, uint32_t fec_lp, uint32_t bandwidth,
                   int transmission, uint32_t guard, int hierarchy)
 {
-    return d->module->SetDVBT(freq, fec_hp, fec_lp,
+    return d->module->SetDVBT(freq / 1000, fec_hp, fec_lp,
                               bandwidth, transmission, guard, hierarchy);
 }
 
@@ -247,12 +247,12 @@ int dvb_set_dvbt2 (dvb_device_t *, uint32_t /*freq*/, const char * /*mod*/,
 /* ATSC */
 int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char * /*mod*/)
 {
-    return d->module->SetATSC(freq);
+    return d->module->SetATSC(freq / 1000);
 }
 
 int dvb_set_cqam (dvb_device_t *d, uint32_t freq, const char * /*mod*/)
 {
-    return d->module->SetCQAM(freq);
+    return d->module->SetCQAM(freq / 1000);
 }
 
 
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index 3cdcd3f..de9dbd5 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -61,10 +61,10 @@ int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
                   uint32_t srate, uint32_t fec);
 
 /* DVB-S */
-int dvb_set_dvbs (dvb_device_t *, uint32_t freq, uint32_t srate, uint32_t fec);
-int dvb_set_dvbs2 (dvb_device_t *, uint32_t freq, const char *mod,
+int dvb_set_dvbs (dvb_device_t *, uint64_t freq, uint32_t srate, uint32_t fec);
+int dvb_set_dvbs2 (dvb_device_t *, uint64_t freq, const char *mod,
                    uint32_t srate, uint32_t fec, int pilot, int rolloff);
-int dvb_set_sec (dvb_device_t *, uint32_t freq, char pol,
+int dvb_set_sec (dvb_device_t *, uint64_t freq, char pol,
                  uint32_t lowf, uint32_t highf, uint32_t switchf);
 
 /* DVB-T */
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index b6c22f1..8e84345 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -615,7 +615,7 @@ int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr,
         return -1;
     return dvb_set_props (d, 6, DTV_CLEAR, 0,
                           DTV_DELIVERY_SYSTEM, SYS_DVBC_ANNEX_AC,
-                          DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod,
+                          DTV_FREQUENCY, freq, DTV_MODULATION, mod,
                           DTV_SYMBOL_RATE, srate, DTV_INNER_FEC, fec);
 }
 
@@ -633,9 +633,11 @@ static unsigned dvb_parse_polarization (char pol)
     return dvb_parse_int (pol, tab, 5, SEC_VOLTAGE_OFF);
 }
 
-int dvb_set_sec (dvb_device_t *d, uint32_t freq, char pol,
+int dvb_set_sec (dvb_device_t *d, uint64_t freq_Hz, char pol,
                  uint32_t lowf, uint32_t highf, uint32_t switchf)
 {
+    uint32_t freq = freq_Hz / 1000;
+
     /* Always try to configure high voltage, but only warn on enable failure */
     int val = var_InheritBool (d->obj, "dvb-high-voltage");
     if (ioctl (d->frontend, FE_ENABLE_HIGH_LNB_VOLTAGE, &val) < 0 && val)
@@ -656,10 +658,10 @@ int dvb_set_sec (dvb_device_t *d, uint32_t freq, char pol,
              {  2500,  2700,  3650,     0 }, /* S band */
              {   950,  2150,     0,     0 }, /* adjusted IF (L band) */
         };
-        uint_fast16_t mhz = freq / 1000;
+        uint_fast16_t mHz = freq / 1000;
 
         for (size_t i = 0; i < sizeof (tab) / sizeof (tab[0]); i++)
-             if (mhz >= tab[i].min && mhz <= tab[i].max)
+             if (mHz >= tab[i].min && mHz <= tab[i].max)
              {
                  lowf = tab[i].low * 1000;
                  highf = tab[i].high * 1000;
@@ -732,8 +734,10 @@ 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, uint32_t fec)
+int dvb_set_dvbs (dvb_device_t *d, uint64_t freq_Hz,
+                  uint32_t srate, uint32_t fec)
 {
+    uint32_t freq = freq_Hz / 1000;
     fec = dvb_parse_fec (fec);
 
     if (dvb_find_frontend (d, FE_QPSK, FE_IS_STUPID))
@@ -743,9 +747,10 @@ int dvb_set_dvbs (dvb_device_t *d, uint32_t freq, uint32_t srate, uint32_t fec)
                           DTV_INNER_FEC, fec);
 }
 
-int dvb_set_dvbs2 (dvb_device_t *d, uint32_t freq, const char *modstr,
+int dvb_set_dvbs2 (dvb_device_t *d, uint64_t freq_Hz, const char *modstr,
                    uint32_t srate, uint32_t fec, int pilot, int rolloff)
 {
+    uint32_t freq = freq_Hz / 1000;
     unsigned mod = dvb_parse_modulation (modstr, QPSK);
     fec = dvb_parse_fec (fec);
 



More information about the vlc-commits mailing list