Commit ef0e4ce4 authored by Rémi Denis-Courmont's avatar 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).
parent 5a9f4ce5
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#define CREATE_TEXT N_("Network name to create") #define CREATE_TEXT N_("Network name to create")
#define CREATE_LONGTEXT N_("Create unique name in the System Tuning Spaces") #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_( \ #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.")
...@@ -350,8 +350,8 @@ struct delsys ...@@ -350,8 +350,8 @@ struct delsys
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 *, unsigned); static int Tune (vlc_object_t *, dvb_device_t *, const delsys_t *, uint64_t);
static unsigned var_InheritFrequency (vlc_object_t *); static uint64_t var_InheritFrequency (vlc_object_t *);
static int Open (vlc_object_t *obj) static int Open (vlc_object_t *obj)
{ {
...@@ -372,13 +372,13 @@ static int Open (vlc_object_t *obj) ...@@ -372,13 +372,13 @@ static int Open (vlc_object_t *obj)
sys->dev = dev; sys->dev = dev;
access->p_sys = sys; access->p_sys = sys;
unsigned freq = var_InheritFrequency (obj); uint64_t freq = var_InheritFrequency (obj);
if (freq != 0) if (freq != 0)
{ {
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 %u kHz failed", freq); msg_Err (obj, "tuning to %"PRIu64" Hz 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"
...@@ -559,7 +559,7 @@ static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev) ...@@ -559,7 +559,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,
unsigned freq) uint64_t 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"))
...@@ -568,14 +568,14 @@ static int Tune (vlc_object_t *obj, dvb_device_t *dev, const delsys_t *delsys, ...@@ -568,14 +568,14 @@ 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) static uint64_t var_InheritFrequency (vlc_object_t *obj)
{ {
unsigned freq = var_InheritInteger (obj, "dvb-frequency"); uint64_t freq = var_InheritInteger (obj, "dvb-frequency");
if (freq >= 108000000) if (freq <= 108000000)
{ {
msg_Err (obj, "%u kHz frequency is too high.", freq); msg_Err (obj, "%"PRIu64" Hz carrier frequency is too low.", freq);
freq /= 1000; freq *= 1000;
msg_Info (obj, "Assuming %u kHz carrier frequency instead.", freq); msg_Info (obj, "Assuming %"PRIu64" Hz frequency instead.", freq);
} }
return freq; return freq;
} }
......
...@@ -197,29 +197,29 @@ int dvb_tune (dvb_device_t *d) ...@@ -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, int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *mod,
uint32_t srate, uint32_t /*fec*/) uint32_t srate, uint32_t /*fec*/)
{ {
return d->module->SetDVBC (freq, mod, srate); return d->module->SetDVBC (freq / 1000, mod, srate);
} }
/* DVB-S */ /* 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->srate = srate;
d->fec = fec; d->fec = fec;
return d->module->SetDVBS(d->frequency, d->srate, d->fec, d->inversion, return d->module->SetDVBS(d->frequency, d->srate, d->fec, d->inversion,
d->pol, d->lowf, d->highf, d->switchf); 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*/) uint32_t /*srate*/, uint32_t /*fec*/, int /*pilot*/, int /*rolloff*/)
{ {
return VLC_EGENERIC; 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) uint32_t lowf, uint32_t highf, uint32_t switchf)
{ {
d->frequency = freq; d->frequency = freq / 1000;
d->pol = pol; d->pol = pol;
d->lowf = lowf; d->lowf = lowf;
d->highf = highf; d->highf = highf;
...@@ -233,7 +233,7 @@ int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char * /*mod*/, ...@@ -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, uint32_t fec_hp, uint32_t fec_lp, uint32_t bandwidth,
int transmission, uint32_t guard, int hierarchy) 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); bandwidth, transmission, guard, hierarchy);
} }
...@@ -247,12 +247,12 @@ int dvb_set_dvbt2 (dvb_device_t *, uint32_t /*freq*/, const char * /*mod*/, ...@@ -247,12 +247,12 @@ int dvb_set_dvbt2 (dvb_device_t *, uint32_t /*freq*/, const char * /*mod*/,
/* ATSC */ /* ATSC */
int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char * /*mod*/) 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*/) 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);
} }
......
...@@ -61,10 +61,10 @@ int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod, ...@@ -61,10 +61,10 @@ int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, uint32_t fec); uint32_t srate, uint32_t fec);
/* DVB-S */ /* DVB-S */
int dvb_set_dvbs (dvb_device_t *, uint32_t freq, uint32_t srate, uint32_t fec); int dvb_set_dvbs (dvb_device_t *, uint64_t freq, uint32_t srate, uint32_t fec);
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); 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); uint32_t lowf, uint32_t highf, uint32_t switchf);
/* DVB-T */ /* DVB-T */
......
...@@ -615,7 +615,7 @@ int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr, ...@@ -615,7 +615,7 @@ int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr,
return -1; return -1;
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 * 1000, 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);
} }
...@@ -633,9 +633,11 @@ static unsigned dvb_parse_polarization (char pol) ...@@ -633,9 +633,11 @@ static unsigned dvb_parse_polarization (char pol)
return dvb_parse_int (pol, tab, 5, SEC_VOLTAGE_OFF); 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 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 */ /* Always try to configure high voltage, but only warn on enable failure */
int val = var_InheritBool (d->obj, "dvb-high-voltage"); int val = var_InheritBool (d->obj, "dvb-high-voltage");
if (ioctl (d->frontend, FE_ENABLE_HIGH_LNB_VOLTAGE, &val) < 0 && val) 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, ...@@ -656,10 +658,10 @@ int dvb_set_sec (dvb_device_t *d, uint32_t freq, char pol,
{ 2500, 2700, 3650, 0 }, /* S band */ { 2500, 2700, 3650, 0 }, /* S band */
{ 950, 2150, 0, 0 }, /* adjusted IF (L 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++) 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; lowf = tab[i].low * 1000;
highf = tab[i].high * 1000; highf = tab[i].high * 1000;
...@@ -732,8 +734,10 @@ known: ...@@ -732,8 +734,10 @@ known:
return dvb_set_props (d, 2, DTV_FREQUENCY, freq, DTV_TONE, tone); 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); fec = dvb_parse_fec (fec);
if (dvb_find_frontend (d, FE_QPSK, FE_IS_STUPID)) 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) ...@@ -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); 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 srate, uint32_t fec, int pilot, int rolloff)
{ {
uint32_t freq = freq_Hz / 1000;
unsigned mod = dvb_parse_modulation (modstr, QPSK); unsigned mod = dvb_parse_modulation (modstr, QPSK);
fec = dvb_parse_fec (fec); fec = dvb_parse_fec (fec);
......
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