Commit a970fb75 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

DTV: pass FEC parameters as integers internally

parent 223d4246
...@@ -91,7 +91,7 @@ static const char *const auto_off_on_user[] = { N_("Automatic"), ...@@ -91,7 +91,7 @@ static const char *const auto_off_on_user[] = { N_("Automatic"),
#define CODE_RATE_LONGTEXT N_( \ #define CODE_RATE_LONGTEXT N_( \
"The code rate for Forward Error Correction can be specified.") "The code rate for Forward Error Correction can be specified.")
static const char *const code_rate_vlc[] = { "", static const char *const code_rate_vlc[] = { "",
"none", /*"1/4", "1/3",*/ "1/2", "3/5", "2/3", "3/4", "0", /*"1/4", "1/3",*/ "1/2", "3/5", "2/3", "3/4",
"4/5", "5/6", "6/7", "7/8", "8/9", "9/10", "4/5", "5/6", "6/7", "7/8", "8/9", "9/10",
}; };
static const char *const code_rate_user[] = { N_("Automatic"), static const char *const code_rate_user[] = { N_("Automatic"),
...@@ -252,13 +252,9 @@ vlc_module_begin () ...@@ -252,13 +252,9 @@ vlc_module_begin ()
add_integer ("dvb-srate", 0, SRATE_TEXT, SRATE_LONGTEXT, false) add_integer ("dvb-srate", 0, SRATE_TEXT, SRATE_LONGTEXT, false)
change_integer_range (0, UINT64_C(0xffffffff)) change_integer_range (0, UINT64_C(0xffffffff))
change_safe () change_safe ()
add_string ("dvb-code-rate", "", CODE_RATE_TEXT, CODE_RATE_LONGTEXT, true) add_string ("dvb-fec", "", CODE_RATE_TEXT, CODE_RATE_LONGTEXT, true)
change_string_list (code_rate_vlc, code_rate_user, NULL) change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe () change_safe ()
add_integer ("dvb-fec", 9, " ", " ", true)
change_integer_range (0, 9)
change_private ()
change_safe ()
set_section (N_("DVB-S2 parameters"), NULL) set_section (N_("DVB-S2 parameters"), NULL)
add_integer ("dvb-pilot", -1, PILOT_TEXT, PILOT_TEXT, true) add_integer ("dvb-pilot", -1, PILOT_TEXT, PILOT_TEXT, true)
change_integer_list (auto_off_on_vlc, auto_off_on_user) change_integer_list (auto_off_on_vlc, auto_off_on_user)
...@@ -533,23 +529,34 @@ static unsigned var_InheritFrequency (vlc_object_t *obj) ...@@ -533,23 +529,34 @@ static unsigned var_InheritFrequency (vlc_object_t *obj)
return freq; return freq;
} }
static char *var_InheritCodeRate (vlc_object_t *obj) static uint32_t var_InheritCodeRate (vlc_object_t *obj, const char *varname)
{ {
char *code_rate = var_InheritString (obj, "dvb-code-rate"); char *code_rate = var_InheritString (obj, varname);
if (code_rate != NULL) if (code_rate == NULL)
return code_rate; return VLC_FEC_AUTO;
/* Backward compatibility with VLC < 1.2 (= Linux DVBv3 enum) */ uint16_t a, b;
unsigned fec = var_InheritInteger (obj, "dvb-fec"); int v = sscanf (code_rate, "%"SCNu16"/%"SCNu16, &a, &b);
if (fec < 9) free (code_rate);
switch (v)
{ {
static const char linux_dvb[9][5] = { case 2:
"none", "1/2", "2/3", "3/4", "4/5", "5/6", "6/7", "7/8" }; return VLC_FEC(a, b);
msg_Warn (obj, "\"fec=%u\" option is obsolete. " case 1:
"Use \"code-rate=%s\" instead.", fec, linux_dvb[fec]); if (a == 0)
return strdup (linux_dvb[fec]); return 0;
/* Backward compatibility with VLC < 1.2 (= Linux DVBv3 enum) */
if (a < 9)
{
msg_Warn (obj, "\"%s=%"PRIu16"\" option is obsolete. "
"Use \"%s=%"PRIu16"/%"PRIu16"\" instead.",
varname + 4, a, varname + 4, a, a + 1);
return VLC_FEC(a, a + 1);
}
else
msg_Warn (obj, "\"fec=9\" option is obsolete.");
} }
return NULL; return VLC_FEC_AUTO;
} }
static char *var_InheritModulation (vlc_object_t *obj) static char *var_InheritModulation (vlc_object_t *obj)
...@@ -637,11 +644,10 @@ const delsys_t cqam = { .setup = cqam_setup }; ...@@ -637,11 +644,10 @@ const delsys_t cqam = { .setup = cqam_setup };
static int dvbc_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned 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); uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
unsigned srate = var_InheritInteger (obj, "dvb-srate"); unsigned srate = var_InheritInteger (obj, "dvb-srate");
int ret = dvb_set_dvbc (dev, freq, mod, srate, fec); int ret = dvb_set_dvbc (dev, freq, mod, srate, fec);
free (fec);
free (mod); free (mod);
return ret; return ret;
} }
...@@ -689,11 +695,10 @@ static int sec_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq) ...@@ -689,11 +695,10 @@ static int sec_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq) static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{ {
char *fec = var_InheritCodeRate (obj); uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
uint32_t srate = var_InheritInteger (obj, "dvb-srate"); uint32_t srate = var_InheritInteger (obj, "dvb-srate");
int ret = dvb_set_dvbs (dev, freq, srate, fec); int ret = dvb_set_dvbs (dev, freq, srate, fec);
free (fec);
if (ret == 0) if (ret == 0)
ret = sec_setup (obj, dev, freq); ret = sec_setup (obj, dev, freq);
return ret; return ret;
...@@ -702,13 +707,12 @@ static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq) ...@@ -702,13 +707,12 @@ static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
static int dvbs2_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned 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); uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
uint32_t srate = var_InheritInteger (obj, "dvb-srate"); uint32_t srate = var_InheritInteger (obj, "dvb-srate");
int pilot = var_InheritInteger (obj, "dvb-pilot"); int pilot = var_InheritInteger (obj, "dvb-pilot");
int rolloff = var_InheritInteger (obj, "dvb-rolloff"); int rolloff = var_InheritInteger (obj, "dvb-rolloff");
int ret = dvb_set_dvbs2 (dev, freq, mod, srate, fec, pilot, rolloff); int ret = dvb_set_dvbs2 (dev, freq, mod, srate, fec, pilot, rolloff);
free (fec);
free (mod); free (mod);
if (ret == 0) if (ret == 0)
ret = sec_setup (obj, dev, freq); ret = sec_setup (obj, dev, freq);
...@@ -723,16 +727,14 @@ const delsys_t dvbs2 = { .setup = dvbs2_setup }; ...@@ -723,16 +727,14 @@ const delsys_t dvbs2 = { .setup = dvbs2_setup };
static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned 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"); uint32_t fec_hp = var_InheritCodeRate (obj, "dvb-code-rate-hp");
char *fec_lp = var_InheritString (obj, "dvb-code-rate-lp"); uint32_t fec_lp = var_InheritCodeRate (obj, "dvb-code-rate-lp");
uint32_t guard = var_InheritGuardInterval (obj); uint32_t guard = var_InheritGuardInterval (obj);
uint32_t bw = var_InheritInteger (obj, "dvb-bandwidth"); uint32_t bw = var_InheritInteger (obj, "dvb-bandwidth");
int tx = var_InheritInteger (obj, "dvb-transmission"); int tx = var_InheritInteger (obj, "dvb-transmission");
int h = var_InheritInteger (obj, "dvb-hierarchy"); int h = var_InheritInteger (obj, "dvb-hierarchy");
int ret = dvb_set_dvbt (dev, freq, mod, fec_hp, fec_lp, bw, tx, guard, h); int ret = dvb_set_dvbt (dev, freq, mod, fec_hp, fec_lp, bw, tx, guard, h);
free (fec_lp);
free (fec_hp);
free (mod); free (mod);
return ret; return ret;
} }
......
...@@ -40,24 +40,25 @@ float dvb_get_snr (dvb_device_t *); ...@@ -40,24 +40,25 @@ float dvb_get_snr (dvb_device_t *);
int dvb_set_inversion (dvb_device_t *, int); int dvb_set_inversion (dvb_device_t *, int);
int dvb_tune (dvb_device_t *); int dvb_tune (dvb_device_t *);
#define VLC_FEC(a,b) (((a) << 16u) | (b))
#define VLC_FEC_AUTO 0xFFFFFFFF
#define VLC_GUARD(a,b) (((a) << 16u) | (b)) #define VLC_GUARD(a,b) (((a) << 16u) | (b))
#define VLC_GUARD_AUTO 0xFFFFFFFF #define VLC_GUARD_AUTO 0xFFFFFFFF
/* DVB-C */ /* DVB-C */
int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod, int dvb_set_dvbc (dvb_device_t *, uint32_t freq, const char *mod,
uint32_t srate, const char *fec); uint32_t srate, uint32_t fec);
/* DVB-S */ /* DVB-S */
int dvb_set_dvbs (dvb_device_t *, uint32_t freq, uint32_t srate, int dvb_set_dvbs (dvb_device_t *, uint32_t freq, uint32_t srate, uint32_t fec);
const char *fec);
int dvb_set_dvbs2 (dvb_device_t *, uint32_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, 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 *, uint32_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 */
int dvb_set_dvbt (dvb_device_t *, uint32_t freq, const char *mod, int dvb_set_dvbt (dvb_device_t *, uint32_t freq, const char *mod,
const char *fec_hp, const char *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);
/* ATSC */ /* ATSC */
......
...@@ -140,24 +140,26 @@ static int dvb_parse_modulation (const char *str, int def) ...@@ -140,24 +140,26 @@ static int dvb_parse_modulation (const char *str, int def)
return dvb_parse_str (str, mods, sizeof (mods) / sizeof (*mods), 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 }, { 0, FEC_NONE },
{ "1/2", FEC_1_2 }, { VLC_FEC(1,2), FEC_1_2 },
// TODO: 1/3 // TODO: 1/3
// TODO: 1/4 // TODO: 1/4
{ "2/3", FEC_2_3 }, { VLC_FEC(2,3), FEC_2_3 },
{ "3/4", FEC_3_4 }, { VLC_FEC(3,4), FEC_3_4 },
{ "4/5", FEC_4_5 }, { VLC_FEC(3,5), FEC_3_5 },
{ "5/6", FEC_5_6 }, { VLC_FEC(4,5), FEC_4_5 },
{ "6/7", FEC_6_7 }, { VLC_FEC(5,6), FEC_5_6 },
{ "7/8", FEC_7_8 }, { VLC_FEC(6,7), FEC_6_7 },
{ "8/9", FEC_8_9 }, { VLC_FEC(7,8), FEC_7_8 },
{ "9/10", FEC_9_10 }, { 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); FEC_AUTO);
} }
...@@ -531,10 +533,10 @@ int dvb_tune (dvb_device_t *d) ...@@ -531,10 +533,10 @@ int dvb_tune (dvb_device_t *d)
/*** DVB-C ***/ /*** DVB-C ***/
int dvb_set_dvbc (dvb_device_t *d, uint32_t freq, const char *modstr, 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 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, return dvb_set_props (d, 6, DTV_CLEAR, 0,
DTV_DELIVERY_SYSTEM, SYS_DVBC_ANNEX_AC, DTV_DELIVERY_SYSTEM, SYS_DVBC_ANNEX_AC,
...@@ -655,10 +657,9 @@ known: ...@@ -655,10 +657,9 @@ 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, int dvb_set_dvbs (dvb_device_t *d, uint32_t freq, uint32_t srate, uint32_t fec)
uint32_t srate, const char *fecstr)
{ {
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, return dvb_set_props (d, 5, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_DVBS,
DTV_FREQUENCY, freq, DTV_SYMBOL_RATE, srate, DTV_FREQUENCY, freq, DTV_SYMBOL_RATE, srate,
...@@ -666,10 +667,10 @@ int dvb_set_dvbs (dvb_device_t *d, uint32_t freq, ...@@ -666,10 +667,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, 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 mod = dvb_parse_modulation (modstr, QPSK);
unsigned fec = dvb_parse_fec (fecstr); fec = dvb_parse_fec (fec);
switch (pilot) switch (pilot)
{ {
...@@ -742,12 +743,12 @@ static int dvb_parse_hierarchy (int i) ...@@ -742,12 +743,12 @@ static int dvb_parse_hierarchy (int i)
} }
int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr, int dvb_set_dvbt (dvb_device_t *d, uint32_t freq, const char *modstr,
const char *fechstr, const char *feclstr, uint32_t bandwidth, uint32_t fec_hp, uint32_t fec_lp, uint32_t bandwidth,
int transmit_mode, uint32_t guard, int hierarchy) int transmit_mode, uint32_t guard, int hierarchy)
{ {
uint32_t mod = dvb_parse_modulation (modstr, QAM_AUTO); uint32_t mod = dvb_parse_modulation (modstr, QAM_AUTO);
uint32_t fec_hp = dvb_parse_fec (fechstr); fec_hp = dvb_parse_fec (fec_hp);
uint32_t fec_lp = dvb_parse_fec (feclstr); fec_lp = dvb_parse_fec (fec_lp);
bandwidth *= 1000000; bandwidth *= 1000000;
transmit_mode = dvb_parse_transmit_mode (transmit_mode); transmit_mode = dvb_parse_transmit_mode (transmit_mode);
guard = dvb_parse_guard (guard); guard = dvb_parse_guard (guard);
......
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