Commit 849c98b3 authored by Rémi Denis-Courmont's avatar 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.
parent a5444c71
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"Only useful programs are normally demultiplexed from the transponder. " \ "Only useful programs are normally demultiplexed from the transponder. " \
"This option will disable demultiplexing and receive all programs.") "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_( \ #define FREQ_LONGTEXT N_( \
"TV channels are grouped by transponder (a.k.a. multiplex) " \ "TV channels are grouped by transponder (a.k.a. multiplex) " \
"on a given frequency. This is required to tune the receiver.") "on a given frequency. This is required to tune the receiver.")
...@@ -171,7 +171,7 @@ vlc_module_begin () ...@@ -171,7 +171,7 @@ vlc_module_begin ()
add_bool ("dvb-budget-mode", false, BUDGET_TEXT, BUDGET_LONGTEXT, true) add_bool ("dvb-budget-mode", false, BUDGET_TEXT, BUDGET_LONGTEXT, true)
#endif #endif
add_integer ("dvb-frequency", 0, FREQ_TEXT, FREQ_LONGTEXT, false) 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 () change_safe ()
add_integer ("dvb-inversion", -1, INVERSION_TEXT, INVERSION_LONGTEXT, true) add_integer ("dvb-inversion", -1, INVERSION_TEXT, INVERSION_LONGTEXT, true)
change_integer_list (auto_off_on_vlc, auto_off_on_user) change_integer_list (auto_off_on_vlc, auto_off_on_user)
...@@ -200,7 +200,7 @@ vlc_module_begin () ...@@ -200,7 +200,7 @@ vlc_module_begin ()
change_integer_list (hierarchy_vlc, hierarchy_user) change_integer_list (hierarchy_vlc, hierarchy_user)
change_safe () change_safe ()
set_section (N_("Cable and satellite parameters"), NULL) set_section (N_("Cable and satellite reception parameters"), NULL)
add_string ("dvb-modulation", 0, add_string ("dvb-modulation", 0,
MODULATION_TEXT, MODULATION_LONGTEXT, false) MODULATION_TEXT, MODULATION_LONGTEXT, false)
change_string_list (modulation_vlc, modulation_user, NULL) change_string_list (modulation_vlc, modulation_user, NULL)
...@@ -254,14 +254,15 @@ struct access_sys_t ...@@ -254,14 +254,15 @@ struct access_sys_t
struct delsys 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 */ /* TODO: scan stuff */
}; };
static block_t *Read (access_t *); static block_t *Read (access_t *);
static int Control (access_t *, int, va_list); static int Control (access_t *, int, va_list);
static const delsys_t *GuessSystem (const char *, dvb_device_t *); 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) static int Open (vlc_object_t *obj)
{ {
...@@ -271,7 +272,7 @@ static int Open (vlc_object_t *obj) ...@@ -271,7 +272,7 @@ static int Open (vlc_object_t *obj)
return VLC_ENOMEM; return VLC_ENOMEM;
var_LocationParse (obj, access->psz_location, "dvb-"); 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); dvb_device_t *dev = dvb_open (obj, freq != 0);
if (dev == NULL) if (dev == NULL)
...@@ -288,7 +289,7 @@ static int Open (vlc_object_t *obj) ...@@ -288,7 +289,7 @@ static int Open (vlc_object_t *obj)
const delsys_t *delsys = GuessSystem (access->psz_access, dev); const delsys_t *delsys = GuessSystem (access->psz_access, dev);
if (delsys == NULL || Tune (obj, dev, delsys, freq)) 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"), dialog_Fatal (obj, N_("Digital broadcasting"),
N_("The selected digital tuner does not support " N_("The selected digital tuner does not support "
"the specified parameters.\n" "the specified parameters.\n"
...@@ -459,7 +460,7 @@ static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev) ...@@ -459,7 +460,7 @@ static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev)
/** Set parameters and tune the device */ /** Set parameters and tune the device */
static int Tune (vlc_object_t *obj, dvb_device_t *dev, const delsys_t *delsys, 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) if (delsys->setup (obj, dev, freq)
|| dvb_set_inversion (dev, var_InheritInteger (obj, "dvb-inversion")) || 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, ...@@ -468,6 +469,18 @@ static int Tune (vlc_object_t *obj, dvb_device_t *dev, const delsys_t *delsys,
return VLC_SUCCESS; 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) static char *var_InheritCodeRate (vlc_object_t *obj)
{ {
char *code_rate = var_InheritString (obj, "dvb-code-rate"); char *code_rate = var_InheritString (obj, "dvb-code-rate");
...@@ -520,7 +533,7 @@ static char *var_InheritModulation (vlc_object_t *obj) ...@@ -520,7 +533,7 @@ static char *var_InheritModulation (vlc_object_t *obj)
/*** ATSC ***/ /*** 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); char *mod = var_InheritModulation (obj);
...@@ -533,7 +546,7 @@ const delsys_t atsc = { .setup = atsc_setup }; ...@@ -533,7 +546,7 @@ const delsys_t atsc = { .setup = atsc_setup };
/*** DVB-C ***/ /*** 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 *mod = var_InheritModulation (obj);
char *fec = var_InheritCodeRate (obj); char *fec = var_InheritCodeRate (obj);
...@@ -549,7 +562,7 @@ const delsys_t dvbc = { .setup = dvbc_setup }; ...@@ -549,7 +562,7 @@ const delsys_t dvbc = { .setup = dvbc_setup };
/*** DVB-S ***/ /*** 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); char *fec = var_InheritCodeRate (obj);
uint32_t srate = var_InheritInteger (obj, "dvb-srate"); 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) ...@@ -562,7 +575,7 @@ static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
return ret; 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 *mod = var_InheritModulation (obj);
char *fec = var_InheritCodeRate (obj); char *fec = var_InheritCodeRate (obj);
...@@ -582,7 +595,7 @@ const delsys_t dvbs2 = { .setup = dvbs2_setup }; ...@@ -582,7 +595,7 @@ const delsys_t dvbs2 = { .setup = dvbs2_setup };
/*** DVB-T ***/ /*** 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 *mod = var_InheritModulation (obj);
char *fec_hp = var_InheritString (obj, "dvb-code-rate-hp"); char *fec_hp = var_InheritString (obj, "dvb-code-rate-hp");
......
...@@ -45,9 +45,9 @@ int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod, ...@@ -45,9 +45,9 @@ int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, const char *fec); uint32_t srate, const char *fec);
/* DVB-S */ /* 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); 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); uint32_t srate, const char *fec, int pilot, int rolloff);
int dvb_set_sec (dvb_device_t *, bool tone, int voltage, bool high_voltage); int dvb_set_sec (dvb_device_t *, bool tone, int voltage, bool high_voltage);
/* XXX^^ */ /* XXX^^ */
......
...@@ -530,27 +530,25 @@ int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr, ...@@ -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, return dvb_set_props (d, 6, DTV_CLEAR, 0,
DTV_DELIVERY_SYSTEM, SYS_DVBC_ANNEX_AC, 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); DTV_SYMBOL_RATE, srate, DTV_INNER_FEC, fec);
} }
/*** DVB-S ***/ /*** 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) uint32_t srate, const char *fecstr)
{ {
unsigned f = freq / 1000;
unsigned fec = dvb_parse_fec (fecstr); unsigned fec = dvb_parse_fec (fecstr);
return dvb_set_props (d, 5, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBS, 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); 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) uint32_t srate, const char *fecstr, int pilot, int rolloff)
{ {
unsigned f = freq / 1000;
unsigned mod = dvb_parse_modulation (modstr, QPSK); unsigned mod = dvb_parse_modulation (modstr, QPSK);
unsigned fec = dvb_parse_fec (fecstr); unsigned fec = dvb_parse_fec (fecstr);
...@@ -570,7 +568,7 @@ int dvb_set_dvbs2 (dvb_device_t *d, uint64_t freq, const char *modstr, ...@@ -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, 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_SYMBOL_RATE, srate, DTV_INNER_FEC, fec,
DTV_PILOT, pilot, DTV_ROLLOFF, rolloff); DTV_PILOT, pilot, DTV_ROLLOFF, rolloff);
} }
...@@ -635,7 +633,7 @@ int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr, ...@@ -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); uint32_t hierarchy = dvb_parse_hierarchy (hierarchy_val);
return dvb_set_props (d, 10, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBT, 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_CODE_RATE_HP, fec_hp, DTV_CODE_RATE_LP, fec_lp,
DTV_BANDWIDTH_HZ, bandwidth, DTV_BANDWIDTH_HZ, bandwidth,
DTV_TRANSMISSION_MODE, transmit_mode, DTV_TRANSMISSION_MODE, transmit_mode,
...@@ -650,5 +648,5 @@ int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char *modstr) ...@@ -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); unsigned mod = dvb_parse_modulation (modstr, VSB_8);
return dvb_set_props (d, 4, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_ATSC, 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);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment