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

DTV: add ISDB-T (untested and exclusing sound broadcasting)

parent 7f24aa81
......@@ -58,6 +58,9 @@
"on a given frequency. This is required to tune the receiver.")
#define MODULATION_TEXT N_("Modulation / Constellation")
#define MODULATION_A_TEXT N_("Layer A modulation")
#define MODULATION_B_TEXT N_("Layer B modulation")
#define MODULATION_C_TEXT N_("Layer C modulation")
#define MODULATION_LONGTEXT N_( \
"The digital signal can be modulated according with different " \
"constellations (depending on the delivery system). " \
......@@ -90,6 +93,9 @@ static const char *const auto_off_on_user[] = { N_("Automatic"),
#define CODE_RATE_TEXT N_("FEC code rate")
#define CODE_RATE_HP_TEXT N_("High-priority code rate")
#define CODE_RATE_LP_TEXT N_("Low-priority code rate")
#define CODE_RATE_A_TEXT N_("Layer A code rate")
#define CODE_RATE_B_TEXT N_("Layer B code rate")
#define CODE_RATE_C_TEXT N_("Layer C code rate")
#define CODE_RATE_LONGTEXT N_( \
"The code rate for Forward Error Correction can be specified.")
static const char *const code_rate_vlc[] = { "",
......@@ -134,6 +140,14 @@ static const char *const hierarchy_user[] = { N_("Automatic"),
N_("None"), "1", "2", "4",
};
#define SEGMENT_COUNT_A_TEXT N_("Layer A segments count")
#define SEGMENT_COUNT_B_TEXT N_("Layer B segments count")
#define SEGMENT_COUNT_C_TEXT N_("Layer C segments count")
#define TIME_INTERLEAVING_A_TEXT N_("Layer A time interleaving")
#define TIME_INTERLEAVING_B_TEXT N_("Layer B time interleaving")
#define TIME_INTERLEAVING_C_TEXT N_("Layer C time interleaving")
#define PILOT_TEXT N_("Pilot")
#define ROLLOFF_TEXT N_("Roll-off factor")
......@@ -219,9 +233,9 @@ vlc_module_begin ()
set_capability ("access", 0)
set_callbacks (Open, Close)
add_shortcut ("dtv", "tv", "dvb", /* "radio", "dab",*/
"cable", "dvb-c",
"cable", "dvb-c", "cqam"
"satellite", "dvb-s", "dvb-s2", "isdb-s",
"terrestrial", "dvb-t", "dvb-t2", "atsc", "cqam")
"terrestrial", "dvb-t", "dvb-t2", "isdb-t", "atsc")
/* All options starting with dvb- can be overridden in the MRL, so they
* must all be "safe". Nevertheless, we do not mark as safe those that are
......@@ -256,14 +270,6 @@ vlc_module_begin ()
add_integer ("dvb-bandwidth", 0, BANDWIDTH_TEXT, BANDWIDTH_TEXT, true)
change_integer_list (bandwidth_vlc, bandwidth_user)
change_safe ()
add_string ("dvb-code-rate-hp", "",
CODE_RATE_HP_TEXT, CODE_RATE_LONGTEXT, false)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_string ("dvb-code-rate-lp", "",
CODE_RATE_LP_TEXT, CODE_RATE_LONGTEXT, false)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_integer ("dvb-transmission", 0,
TRANSMISSION_TEXT, TRANSMISSION_TEXT, true)
change_integer_list (transmission_vlc, transmission_user)
......@@ -271,10 +277,61 @@ vlc_module_begin ()
add_string ("dvb-guard", "", GUARD_TEXT, GUARD_TEXT, true)
change_string_list (guard_vlc, guard_user, NULL)
change_safe ()
set_section (N_("DVB-T reception parameters"), NULL)
add_string ("dvb-code-rate-hp", "",
CODE_RATE_HP_TEXT, CODE_RATE_LONGTEXT, true)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_string ("dvb-code-rate-lp", "",
CODE_RATE_LP_TEXT, CODE_RATE_LONGTEXT, true)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_integer ("dvb-hierarchy", -1, HIERARCHY_TEXT, HIERARCHY_TEXT, true)
change_integer_list (hierarchy_vlc, hierarchy_user)
change_safe ()
set_section (N_("ISDB-T reception parameters"), NULL)
add_string ("dvb-a-modulation", NULL,
MODULATION_A_TEXT, MODULATION_LONGTEXT, true)
change_string_list (modulation_vlc, modulation_user, NULL)
change_safe ()
add_string ("dvb-a-fec", NULL, CODE_RATE_A_TEXT, CODE_RATE_LONGTEXT, true)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_integer ("dvb-a-count", 0, SEGMENT_COUNT_A_TEXT, NULL, true)
change_integer_range (0, 13)
change_safe ()
add_integer ("dvb-a-interleaving", 0, TIME_INTERLEAVING_A_TEXT, NULL, true)
change_integer_range (0, 3)
change_safe ()
add_string ("dvb-b-modulation", NULL,
MODULATION_B_TEXT, MODULATION_LONGTEXT, true)
change_string_list (modulation_vlc, modulation_user, NULL)
change_safe ()
add_string ("dvb-b-fec", NULL, CODE_RATE_B_TEXT, CODE_RATE_LONGTEXT, true)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_integer ("dvb-b-count", 0, SEGMENT_COUNT_B_TEXT, NULL, true)
change_integer_range (0, 13)
change_safe ()
add_integer ("dvb-b-interleaving", 0, TIME_INTERLEAVING_B_TEXT, NULL, true)
change_integer_range (0, 3)
change_safe ()
add_string ("dvb-c-modulation", NULL,
MODULATION_C_TEXT, MODULATION_LONGTEXT, true)
change_string_list (modulation_vlc, modulation_user, NULL)
change_safe ()
add_string ("dvb-c-fec", NULL, CODE_RATE_C_TEXT, CODE_RATE_LONGTEXT, true)
change_string_list (code_rate_vlc, code_rate_user, NULL)
change_safe ()
add_integer ("dvb-c-count", 0, SEGMENT_COUNT_C_TEXT, NULL, true)
change_integer_range (0, 13)
change_safe ()
add_integer ("dvb-c-interleaving", 0, TIME_INTERLEAVING_C_TEXT, NULL, true)
change_integer_range (0, 3)
change_safe ()
set_section (N_("Cable and satellite reception parameters"), NULL)
add_string ("dvb-modulation", NULL,
MODULATION_TEXT, MODULATION_LONGTEXT, false)
......@@ -357,7 +414,7 @@ typedef struct delsys
} delsys_t;
static const delsys_t dvbc, dvbs, dvbs2, dvbt, dvbt2;
static const delsys_t isdbs;
static const delsys_t isdbs, isdbt;
static const delsys_t atsc, cqam;
static block_t *Read (access_t *);
......@@ -568,6 +625,8 @@ static const delsys_t *GuessSystem (const char *scheme, dvb_device_t *dev)
return &dvbt2;
if (!strcasecmp (scheme, "isdb-s"))
return &isdbs;
if (!strcasecmp (scheme, "isdb-t"))
return &isdbt;
unsigned systems = dvb_enum_systems (dev);
if (systems & ATSC)
......@@ -639,9 +698,9 @@ static int modcmp (const void *a, const void *b)
return strcasecmp (a, *(const char *const *)b);
}
static const char *var_InheritModulation (vlc_object_t *obj)
static const char *var_InheritModulation (vlc_object_t *obj, const char *var)
{
char *mod = var_InheritString (obj, "dvb-modulation");
char *mod = var_InheritString (obj, var);
if (mod == NULL)
return "";
......@@ -703,7 +762,7 @@ static unsigned var_InheritGuardInterval (vlc_object_t *obj)
/*** ATSC ***/
static int atsc_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
const char *mod = var_InheritModulation (obj);
const char *mod = var_InheritModulation (obj, "dvb-modulation");
return dvb_set_atsc (dev, freq, mod);
}
......@@ -712,7 +771,7 @@ static const delsys_t atsc = { .setup = atsc_setup };
static int cqam_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
const char *mod = var_InheritModulation (obj);
const char *mod = var_InheritModulation (obj, "dvb-modulation");
return dvb_set_cqam (dev, freq, mod);
}
......@@ -723,7 +782,7 @@ static const delsys_t cqam = { .setup = cqam_setup };
/*** DVB-C ***/
static int dvbc_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
const char *mod = var_InheritModulation (obj);
const char *mod = var_InheritModulation (obj, "dvb-modulation");
uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
unsigned srate = var_InheritInteger (obj, "dvb-srate");
......@@ -784,7 +843,7 @@ static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
static int dvbs2_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
const char *mod = var_InheritModulation (obj);
const char *mod = var_InheritModulation (obj, "dvb-modulation");
uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
uint32_t srate = var_InheritInteger (obj, "dvb-srate");
int pilot = var_InheritInteger (obj, "dvb-pilot");
......@@ -803,7 +862,7 @@ static const delsys_t dvbs2 = { .setup = dvbs2_setup };
/*** DVB-T ***/
static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
const char *mod = var_InheritModulation (obj);
const char *mod = var_InheritModulation (obj, "dvb-modulation");
uint32_t fec_hp = var_InheritCodeRate (obj, "dvb-code-rate-hp");
uint32_t fec_lp = var_InheritCodeRate (obj, "dvb-code-rate-lp");
uint32_t guard = var_InheritGuardInterval (obj);
......@@ -816,7 +875,7 @@ static int dvbt_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
static int dvbt2_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
const char *mod = var_InheritModulation (obj);
const char *mod = var_InheritModulation (obj, "dvb-modulation");
uint32_t fec = var_InheritCodeRate (obj, "dvb-fec");
uint32_t guard = var_InheritGuardInterval (obj);
uint32_t bw = var_InheritInteger (obj, "dvb-bandwidth");
......@@ -841,3 +900,33 @@ static int isdbs_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
}
static const delsys_t isdbs = { .setup = isdbs_setup };
/*** ISDB-T ***/
static int isdbt_setup (vlc_object_t *obj, dvb_device_t *dev, uint64_t freq)
{
isdbt_layer_t layers[3];
uint32_t guard = var_InheritGuardInterval (obj);
uint32_t bw = var_InheritInteger (obj, "dvb-bandwidth");
int tx = var_InheritInteger (obj, "dvb-transmission");
for (unsigned i = 0; i < 3; i++)
{
char varname[sizeof ("dvb-X-interleaving")];
memcpy (varname, "dvb-X-", 4);
varname[4] = 'a' + i;
strcpy (varname + 6, "modulation");
layers[i].modulation = var_InheritModulation (obj, varname);
strcpy (varname + 6, "fec");
layers[i].code_rate = var_InheritCodeRate (obj, varname);
strcpy (varname + 6, "count");
layers[i].segment_count = var_InheritInteger (obj, varname);
strcpy (varname + 6, "interleaving");
layers[i].time_interleaving = var_InheritInteger (obj, varname);
}
return dvb_set_isdbt (dev, freq, bw, tx, guard, layers);
}
static const delsys_t isdbt = { .setup = isdbt_setup };
......@@ -250,6 +250,14 @@ int dvb_set_isdbs (dvb_device_t *, uint64_t /*freq*/, uint16_t /*ts_id*/)
return VLC_EGENERIC;
}
/* ISDB-T */
int dvb_set_isdbt (dvb_device_t *, uint32_t /*freq*/, uint32_t /*bandwidth*/,
int /*transmit_mode*/, uint32_t /*guard*/,
const isdbt_layer_t /*layers*/[3])
{
return VLC_EGENERIC;
}
/* ATSC */
int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char * /*mod*/)
{
......
......@@ -98,20 +98,21 @@ int dvb_set_isdbs (dvb_device_t *, uint64_t freq, uint16_t ts_id);
typedef struct isdbt_layer
{
const char *modulation;
const char *code_rate;
uint32_t code_rate;
uint8_t segment_count;
uint8_t time_interleaving;
} isdbt_layer_t;
int dvb_set_isdbt (dvb_device_t *, uint32_t freq, uint32_t bandwith,
int transmission, uint32_t guard, const isdbt_layer_t[3]);
typedef struct isdbt_sound
{
uint8_t subchannel_id;
uint8_t segment_index; uint8_t segment_cound;
uint8_t segment_index;
uint8_t segment_count;
} isdbt_sound_t;
int dvb_set_isdbt (dvb_device_t *, uint32_t freq, const isdbt_layer_t *a,
const isdbt_layer_t *b, const isdbt_layer_t *c,
const isdbt_sound_t *sb);
# ifdef __cplusplus
}
# endif
......
......@@ -928,6 +928,49 @@ int dvb_set_isdbs (dvb_device_t *d, uint64_t freq_Hz, uint16_t ts_id)
}
/*** ISDB-T ***/
static int dvb_set_isdbt_layer (dvb_device_t *d, unsigned num,
const isdbt_layer_t *l)
{
uint32_t mod = dvb_parse_modulation (l->modulation, QAM_AUTO);
uint32_t fec = dvb_parse_fec (l->code_rate);
uint32_t count = l->segment_count;
uint32_t ti = l->time_interleaving;
num *= DTV_ISDBT_LAYERB_FEC - DTV_ISDBT_LAYERA_FEC;
return dvb_set_props (d, 5, DTV_DELIVERY_SYSTEM, SYS_ISDBT,
DTV_ISDBT_LAYERA_FEC + num, fec,
DTV_ISDBT_LAYERA_MODULATION + num, mod,
DTV_ISDBT_LAYERA_SEGMENT_COUNT + num, count,
DTV_ISDBT_LAYERA_TIME_INTERLEAVING + num, ti);
}
int dvb_set_isdbt (dvb_device_t *d, uint32_t freq, uint32_t bandwidth,
int transmit_mode, uint32_t guard,
const isdbt_layer_t layers[3])
{
#if DVBv5(1)
bandwidth = dvb_parse_bandwidth (bandwidth);
transmit_mode = dvb_parse_transmit_mode (transmit_mode);
guard = dvb_parse_guard (guard);
if (dvb_find_frontend (d, FE_OFDM, FE_IS_STUPID))
return -1;
if (dvb_set_props (d, 5, DTV_CLEAR, 0, DTV_DELIVERY_SYSTEM, SYS_ISDBT,
DTV_FREQUENCY, freq, DTV_BANDWIDTH_HZ, bandwidth,
DTV_GUARD_INTERVAL, guard))
return -1;
for (unsigned i = 0; i < 3; i++)
if (dvb_set_isdbt_layer (d, i, layers + i))
return -1;
return 0;
#else
# warning ISDB-T needs Linux DVB version 5.1 or later.
#endif
}
/*** ATSC ***/
int dvb_set_atsc (dvb_device_t *d, uint32_t freq, const char *modstr)
{
......
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