[vlc-commits] DTV: adjust DVB-S frequency and send tone
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:48:20 2011 +0200| [51a887bbfeb157a110315409e03600874ff5b23e] | committer: Rémi Denis-Courmont
DTV: adjust DVB-S frequency and send tone
This is done according to oscillator configuration.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51a887bbfeb157a110315409e03600874ff5b23e
---
modules/access/dtv/access.c | 61 +++++++++++++++++++++++++++++++-----------
modules/access/dtv/dtv.h | 3 +-
modules/access/dtv/linux.c | 56 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 101 insertions(+), 19 deletions(-)
diff --git a/modules/access/dtv/access.c b/modules/access/dtv/access.c
index c7b825e..277f128 100644
--- a/modules/access/dtv/access.c
+++ b/modules/access/dtv/access.c
@@ -132,6 +132,7 @@ static const char *const hierarchy_user[] = { N_("Automatic"),
};
#define PILOT_TEXT N_("Pilot")
+
#define ROLLOFF_TEXT N_("Roll-off factor")
const int rolloff_vlc[] = { -1,
35, 20, 25,
@@ -155,6 +156,31 @@ static const char *const polarization_user[] = { N_("Unspecified (0V)"),
"the receiver are long, higher voltage may be required.\n" \
"Not all receivers support this.")
+#define LNB_LOW_TEXT N_("Local oscillator low frequency (kHz)")
+#define LNB_HIGH_TEXT N_("Local oscillator high frequency (kHz)")
+#define LNB_LONGTEXT N_( \
+ "The downconverter (LNB) will substract the local oscillator frequency " \
+ "from the satellite transmission frequency. " \
+ "The intermediate frequency (IF) on the RF cable is the result.")
+#define LNB_SWITCH_TEXT N_("Universal LNB switch frequency (kHz)")
+#define LNB_SWITCH_LONGTEXT N_( \
+ "If the satellite transmission frequency exceeds the switch frequency, " \
+ "the oscillator high frequency will be used as reference. " \
+ "Furthermore the automatic continuous 22kHz tone will be sent.")
+#define TONE_TEXT N_("Continuous 22kHz tone")
+#define TONE_LONGTEXT N_( \
+ "A continuous tone at 22kHz can be sent on the cable. " \
+ "This normally selects the higher frequency band from a universal LNB.")
+
+#if 0
+#define SATNO_TEXT N_("DiSEqC LNB number")
+#define SATNO_LONGTEXT N_( \
+ "If the satellite receiver is connected to multiple " \
+ "low noise block-downconverters (LNB) through a DiSEqC 1.0 switch, " \
+ "the correct LNB can be selected (1 to 4). " \
+ "If there is no switch, this parameter should be 0.")
+#endif
+
static int Open (vlc_object_t *);
static void Close (vlc_object_t *);
@@ -166,7 +192,7 @@ vlc_module_begin ()
set_capability ("access", 0)
set_callbacks (Open, Close)
add_shortcut ("dtv", "tv", "dvb", /* "radio", "dab",*/
- "cable", "dvb-c", /*"satellite", "dvb-s", "dvb-s2",*/
+ "cable", "dvb-c", "satellite", "dvb-s", "dvb-s2",
"terrestrial", "dvb-t", "atsc")
/* All options starting with dvb- can be overriden in the MRL, so they
@@ -250,21 +276,21 @@ vlc_module_begin ()
add_bool ("dvb-high-voltage", false,
HIGH_VOLTAGE_TEXT, HIGH_VOLTAGE_LONGTEXT, false)
#endif
-#if 0
- add_integer ("dvb-tone", -1, TONE_TEXT, TONE_LONGTEXT, true)
- change_integer_list (tone_vlc, auto_off_on)
- change_safe ()
- add_integer ("dvb-lnb-lof1", 0, LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT, true)
+ add_integer ("dvb-lnb-low", 0, LNB_LOW_TEXT, LNB_LONGTEXT, true)
change_integer_range (0, 0x7fffffff)
- change_safe ()
- add_integer ("dvb-lnb-lof2", 0, LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT, true)
+ add_deprecated_alias ("dvb-lnb-lof1")
+ add_integer ("dvb-lnb-high", 0, LNB_HIGH_TEXT, LNB_LONGTEXT, true)
change_integer_range (0, 0x7fffffff)
- change_safe ()
- add_integer ("dvb-lnb-slof", 0, LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT, true)
+ add_deprecated_alias ("dvb-lnb-lof2")
+ add_integer ("dvb-lnb-switch", 11700000,
+ LNB_SWITCH_TEXT, LNB_SWITCH_LONGTEXT, true)
change_integer_range (0, 0x7fffffff)
- change_safe ()
+ add_deprecated_alias ("dvb-lnb-slof")
+ add_integer ("dvb-tone", -1, TONE_TEXT, TONE_LONGTEXT, true)
+ change_integer_list (auto_off_on_vlc, auto_off_on_user)
+#if 0
add_integer ("dvb-satno", 0, SATNO_TEXT, SATNO_LONGTEXT, true)
- change_integer_list (satno_vlc, satno_user)
+ change_integer_range (0, 4)
change_safe ()
#endif
vlc_module_end ()
@@ -611,11 +637,14 @@ static char var_InheritPolarization (vlc_object_t *obj)
return pol;
}
-static int sec_setup (vlc_object_t *obj, dvb_device_t *dev)
+static int sec_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
{
char pol = var_InheritPolarization (obj);
+ unsigned lowf = var_InheritInteger (obj, "dvb-lnb-low");
+ unsigned highf = var_InheritInteger (obj, "dvb-lnb-high");
+ unsigned switchf = var_InheritInteger (obj, "dvb-lnb-switch");
- return dvb_set_sec (dev, pol);
+ return dvb_set_sec (dev, freq, pol, lowf, highf, switchf);
}
static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
@@ -627,7 +656,7 @@ static int dvbs_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
int ret = dvb_set_dvbs (dev, freq, srate, fec);
free (fec);
if (ret == 0)
- ret = sec_setup (obj, dev);
+ ret = sec_setup (obj, dev, freq);
return ret;
}
@@ -644,7 +673,7 @@ static int dvbs2_setup (vlc_object_t *obj, dvb_device_t *dev, unsigned freq)
free (fec);
free (mod);
if (ret == 0)
- ret = sec_setup (obj, dev);
+ ret = sec_setup (obj, dev, freq);
return ret;
}
diff --git a/modules/access/dtv/dtv.h b/modules/access/dtv/dtv.h
index c8ffb09..5493db3 100644
--- a/modules/access/dtv/dtv.h
+++ b/modules/access/dtv/dtv.h
@@ -49,7 +49,8 @@ int dvb_set_dvbs (dvb_device_t *, uint32_t freq, uint32_t srate,
const char *fec);
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 *, char pol);
+int dvb_set_sec (dvb_device_t *, uint32_t freq, char pol,
+ uint32_t lowf, uint32_t highf, uint32_t switchf);
/* DVB-T */
int dvb_set_dvbt (dvb_device_t *, uint32_t freq, const char *mod,
diff --git a/modules/access/dtv/linux.c b/modules/access/dtv/linux.c
index 04a5108..268a3e8 100644
--- a/modules/access/dtv/linux.c
+++ b/modules/access/dtv/linux.c
@@ -548,16 +548,68 @@ static unsigned dvb_parse_polarization (char pol)
return dvb_parse_int (pol, tab, 5, SEC_VOLTAGE_OFF);
}
-int dvb_set_sec (dvb_device_t *d, char pol)
+int dvb_set_sec (dvb_device_t *d, uint32_t freq, char pol,
+ uint32_t lowf, uint32_t highf, uint32_t switchf)
{
/* Always try to configure high voltage, but only warn on enable failure */
int val = var_InheritBool (d->obj, "dvb-high-voltage");
if (ioctl (d->frontend, FE_ENABLE_HIGH_LNB_VOLTAGE, &val) < 0 && val)
msg_Err (d->obj, "cannot enable high LNB voltage: %m");
+ /* Windows BDA exposes a higher-level API covering LNB oscillators.
+ * So lets pretend this is platform-specific stuff and do it here. */
+ if (!lowf)
+ { /* Default oscillator frequencies */
+ static const struct
+ {
+ uint16_t min, max, low, high;
+ } tab[] =
+ { /* min max low high */
+ { 10700, 13250, 9750, 10600 }, /* Ku band */
+ { 4500, 4800, 5950, 0 }, /* C band (high) */
+ { 3400, 4200, 5150, 0 }, /* C band (low) */
+ { 2500, 2700, 3650, 0 }, /* S band */
+ { 950, 2150, 0, 0 }, /* adjusted IF (L band) */
+ };
+ uint_fast16_t mhz = freq / 1000;
+
+ for (size_t i = 0; i < sizeof (tab) / sizeof (tab[0]); i++)
+ if (mhz >= tab[i].min && mhz <= tab[i].max)
+ {
+ lowf = tab[i].low * 1000;
+ highf = tab[i].high * 1000;
+ goto known;
+ }
+
+ msg_Err (d->obj, "no known band for frequency %u kHz", freq);
+known:
+ msg_Dbg (d->obj, "selected LNB low: %u kHz, LNB high: %u kHz",
+ lowf, highf);
+ }
+
+ /* Use high oscillator frequency? */
+ bool high = highf != 0 && freq > switchf;
+
+ freq -= high ? highf : lowf;
+ if ((int32_t)freq < 0)
+ freq *= -1;
+ assert (freq < 0x7fffffff);
+
+ /* TODO: DiSEqC */
+
+ /* Continuous tone (to select high oscillator frequency) */
+ int tone;
+ switch (var_InheritInteger (d->obj, "dvb-tone"))
+ {
+ case 0: tone = SEC_TONE_OFF; break;
+ case 1: tone = SEC_TONE_ON; break;
+ default: tone = high ? SEC_TONE_ON : SEC_TONE_OFF;
+ }
+
unsigned voltage = dvb_parse_polarization (pol);
- return dvb_set_prop (d, DTV_VOLTAGE, voltage);
+ return dvb_set_props (d, 3, DTV_FREQUENCY, freq,
+ DTV_VOLTAGE, voltage, DTV_TONE, tone);
}
int dvb_set_dvbs (dvb_device_t *d, uint32_t freq,
More information about the vlc-commits
mailing list