[vlc-commits] DTV: use kHz for all frequencies
Rémi Denis-Courmont
git at videolan.org
Wed Mar 23 18:51:48 CET 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Mar 23 19:12:58 2011 +0200| [849c98b34594a3d3e3daa982ab4204042ac2dd77] | committer: Rémi Denis-Courmont
DTV: use kHz for all frequencies
This is the simplest option. Hz resolution is useless for this purpose,
exhibits so many trailing zeroes that the preferences dialog overflows,
and overflows 32-bits values for satellite carrier frequencies.
This is also the default resolution for BDA. I see no need to copy the
"inconsistent" resolution if Linux-DVB (Hz for C/T, kHz for S).
For backward compatibility, frequencies beyond the radar bands are
divided by 1000. This corresponds to EHF and infrared in kHz.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=849c98b34594a3d3e3daa982ab4204042ac2dd77
---
modules/access/dtv/access.c | 39 ++++++++++++++++++++++++++-------------
modules/access/dtv/dtv.h | 4 ++--
modules/access/dtv/linux.c | 16 +++++++---------
3 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/modules/access/dtv/access.c b/modules/access/dtv/access.c
index 51faf17..902ff0e 100644
--- a/modules/access/dtv/access.c
+++ b/modules/access/dtv/access.c
@@ -50,7 +50,7 @@
"Only useful programs are normally demultiplexed from the transponder. " \
"This option will disable demultiplexing and receive all programs.")
-#define FREQ_TEXT N_("Frequency (Hz)")
+#define FREQ_TEXT N_("Frequency (kHz)")
#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.")
@@ -171,7 +171,7 @@ vlc_module_begin ()
add_bool ("dvb-budget-mode", false, BUDGET_TEXT, BUDGET_LONGTEXT, true)
#endif
add_integer ("dvb-frequency", 0, FREQ_TEXT, FREQ_LONGTEXT, false)
- change_integer_range (0, UINT64_C(0xffffffff) * 1000)
+ change_integer_range (0, 107999999)
change_safe ()
add_integer ("dvb-inversion", -1, INVERSION_TEXT, INVERSION_LONGTEXT, true)
change_integer_list (auto_off_on_vlc, auto_off_on_user)
@@ -200,7 +200,7 @@ vlc_module_begin ()
change_integer_list (hierarchy_vlc, hierarchy_user)
change_safe ()
- set_section (N_("Cable and satellite parameters"), NULL)
+ set_section (N_("Cable and satellite reception parameters"), NULL)
add_string ("dvb-modulation", 0,
MODULATION_TEXT, MODULATION_LONGTEXT, false)
change_string_list (modulation_vlc, modulation_user, NULL)
@@ -254,14 +254,15 @@ struct access_sys_t
struct delsys
{
- int (*setup) (vlc_object_t *, dvb_device_t *, uint64_t freq);
+ int (*setup) (vlc_object_t *, dvb_device_t *, unsigned freq);
/* TODO: scan stuff */
};
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 *, uint64_t);
+static int Tune (vlc_object_t *, dvb_device_t *, const delsys_t *, unsigned);
+static unsigned var_InheritFrequency (vlc_object_t *);
static int Open (vlc_object_t *obj)
{
@@ -271,7 +272,7 @@ static int Open (vlc_object_t *obj)
return VLC_ENOMEM;
var_LocationParse (obj, access->psz_location, "dvb-");
- uint64_t freq = var_InheritInteger (obj, "dvb-frequency");
+ unsigned freq = var_InheritFrequency (obj);
dvb_device_t *dev = dvb_open (obj, freq != 0);
if (dev == NULL)
@@ -288,7 +289,7 @@ static int Open (vlc_object_t *obj)
const delsys_t *delsys = GuessSystem (access->psz_access, dev);
if (delsys == NULL || Tune (obj, dev, delsys, freq))
{
- msg_Err (obj, "tuning to %"PRIu64" Hz failed", freq);
+ msg_Err (obj, "tuning to %u kHz failed", freq);
dialog_Fatal (obj, N_("Digital broadcasting"),
N_("The selected digital tuner does not support "
"the specified parameters.\n"
@@ -459,7 +460,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,
- uint64_t freq)
+ unsigned freq)
{
if (delsys->setup (obj, dev, freq)
|| dvb_set_inversion (dev, var_InheritInteger (obj, "dvb-inversion"))
@@ -468,6 +469,18 @@ 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)
+{
+ unsigned 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);
+ }
+ return freq;
+}
+
static char *var_InheritCodeRate (vlc_object_t *obj)
{
char *code_rate = var_InheritString (obj, "dvb-code-rate");
@@ -520,7 +533,7 @@ static char *var_InheritModulation (vlc_object_t *obj)
/*** ATSC ***/
-static int atsc_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
+static int atsc_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{
char *mod = var_InheritModulation (obj);
@@ -533,7 +546,7 @@ const delsys_t atsc = { .setup = atsc_setup };
/*** DVB-C ***/
-static int dvbc_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
+static int dvbc_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{
char *mod = var_InheritModulation (obj);
char *fec = var_InheritCodeRate (obj);
@@ -549,7 +562,7 @@ const delsys_t dvbc = { .setup = dvbc_setup };
/*** DVB-S ***/
-static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
+static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{
char *fec = var_InheritCodeRate (obj);
uint32_t srate = var_InheritInteger (obj, "dvb-srate");
@@ -562,7 +575,7 @@ static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
return ret;
}
-static int dvbs2_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
+static int dvbs2_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{
char *mod = var_InheritModulation (obj);
char *fec = var_InheritCodeRate (obj);
@@ -582,7 +595,7 @@ const delsys_t dvbs2 = { .setup = dvbs2_setup };
/*** DVB-T ***/
-static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
+static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{
char *mod = var_InheritModulation (obj);
char *fec_hp = var_InheritString (obj, "dvb-code-rate-hp");
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index 0017a6f..7b5d49a 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -45,9 +45,9 @@ int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, const char *fec);
/* DVB-S */
-int dvb_set_dvbs (dvb_device_t *, uint64_t freq, uint32_t srate,
+int dvb_set_dvbs (dvb_device_t *, uint32_t freq, uint32_t srate,
const char *fec);
-int dvb_set_dvbs2 (dvb_device_t *, uint64_t freq, const char *mod,
+int dvb_set_dvbs2 (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, const char *fec, int pilot, int rolloff);
int dvb_set_sec (dvb_device_t *, bool tone, int voltage, bool high_voltage);
/* XXX^^ */
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index 0290789..9416938 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -530,27 +530,25 @@ int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr,
return dvb_set_props (d, 6, DTV_CLEAR, 0,
DTV_DELIVERY_SYSTEM, SYS_DVBC_ANNEX_AC,
- DTV_FREQUENCY, freq, DTV_MODULATION, mod,
+ DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod,
DTV_SYMBOL_RATE, srate, DTV_INNER_FEC, fec);
}
/*** DVB-S ***/
-int dvb_set_dvbs (dvb_device_t *d, uint64_t freq,
+int dvb_set_dvbs (dvb_device_t *d, uint32_t freq,
uint32_t srate, const char *fecstr)
{
- unsigned f = freq / 1000;
unsigned fec = dvb_parse_fec (fecstr);
return dvb_set_props (d, 5, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBS,
- DTV_FREQUENCY, f, DTV_SYMBOL_RATE, srate,
+ DTV_FREQUENCY, freq, DTV_SYMBOL_RATE, srate,
DTV_INNER_FEC, fec);
}
-int dvb_set_dvbs2 (dvb_device_t *d, uint64_t freq, const char *modstr,
+int dvb_set_dvbs2 (dvb_device_t *d, uint32_t freq, const char *modstr,
uint32_t srate, const char *fecstr, int pilot, int rolloff)
{
- unsigned f = freq / 1000;
unsigned mod = dvb_parse_modulation (modstr, QPSK);
unsigned fec = dvb_parse_fec (fecstr);
@@ -570,7 +568,7 @@ int dvb_set_dvbs2 (dvb_device_t *d, uint64_t freq, const char *modstr,
}
return dvb_set_props (d, 8, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBS2,
- DTV_FREQUENCY, f, DTV_MODULATION, mod,
+ DTV_FREQUENCY, freq, DTV_MODULATION, mod,
DTV_SYMBOL_RATE, srate, DTV_INNER_FEC, fec,
DTV_PILOT, pilot, DTV_ROLLOFF, rolloff);
}
@@ -635,7 +633,7 @@ int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr,
uint32_t hierarchy = dvb_parse_hierarchy (hierarchy_val);
return dvb_set_props (d, 10, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBT,
- DTV_FREQUENCY, freq, DTV_MODULATION, mod,
+ 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,
@@ -650,5 +648,5 @@ int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char *modstr)
unsigned mod = dvb_parse_modulation (modstr, VSB_8);
return dvb_set_props (d, 4, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_ATSC,
- DTV_FREQUENCY, freq, DTV_MODULATION, mod);
+ DTV_FREQUENCY, freq * 1000, DTV_MODULATION, mod);
}
More information about the vlc-commits
mailing list