media: vidtv: fix DVB-S/S2 tuning logic

Satellite setups are different than terrestrial and cable ones,
as there is a device coupled at the antenna, called LNBf, which
converts the frequency from a GHz range at C-Band or Ku-Band
into an intermediate frequency at S-Band (ranging up to ~2GHz).

There are several different models of LNBf, with different
IF conversions, but the most common nowadays is called
Universal LNBf. Those got their frequency ranges extended in the
past, when Astra 19.2E sattellite was launched.

The universal LNBf has two local oscilators:

	- 9.75 GHz
	- 10.6 GHz

The first one is used when the frequency is between 10.7 GHz
up to 11.7 GHz. The second one is for frequencies between
11.7 GHz to 12.75 GHz.

With that, the IF signal will be at 950 MHz to 2,150 MHz range.

Add support for doing the above math, and make clear that
the frequencies expected by the driver should be at Ku-Band
range.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab 2020-09-15 08:25:56 +02:00
parent d38829a5e1
commit 9ec6f4bb60
1 changed files with 28 additions and 7 deletions

View File

@ -29,6 +29,12 @@
#define TUNER_DEFAULT_ADDR 0x68
#define DEMOD_DEFAULT_ADDR 0x60
/* LNBf fake parameters: ranges used by an Universal (extended) European LNBf */
#define LNB_CUT_FREQUENCY 11700000
#define LNB_LOW_FREQ 9750000
#define LNB_HIGH_FREQ 10600000
static unsigned int drop_tslock_prob_on_low_snr;
module_param(drop_tslock_prob_on_low_snr, uint, 0);
MODULE_PARM_DESC(drop_tslock_prob_on_low_snr,
@ -53,7 +59,7 @@ static unsigned int vidtv_valid_dvb_t_freqs[NUM_VALID_TUNER_FREQS] = {
module_param_array(vidtv_valid_dvb_t_freqs, uint, NULL, 0);
MODULE_PARM_DESC(vidtv_valid_dvb_t_freqs,
"Valid DVB-T frequencies to simulate");
"Valid DVB-T frequencies to simulate, in Hz");
static unsigned int vidtv_valid_dvb_c_freqs[NUM_VALID_TUNER_FREQS] = {
474000000
@ -61,14 +67,14 @@ static unsigned int vidtv_valid_dvb_c_freqs[NUM_VALID_TUNER_FREQS] = {
module_param_array(vidtv_valid_dvb_c_freqs, uint, NULL, 0);
MODULE_PARM_DESC(vidtv_valid_dvb_c_freqs,
"Valid DVB-C frequencies to simulate");
"Valid DVB-C frequencies to simulate, in Hz");
static unsigned int vidtv_valid_dvb_s_freqs[NUM_VALID_TUNER_FREQS] = {
12551500
11362000
};
module_param_array(vidtv_valid_dvb_s_freqs, uint, NULL, 0);
MODULE_PARM_DESC(vidtv_valid_dvb_s_freqs,
"Valid DVB-C frequencies to simulate");
"Valid DVB-S/S2 frequencies to simulate at Ku-Band, in kHz");
static unsigned int max_frequency_shift_hz;
module_param(max_frequency_shift_hz, uint, 0);
@ -336,11 +342,15 @@ static int vidtv_bridge_probe_demod(struct vidtv_dvb *dvb, u32 n)
static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n)
{
struct vidtv_tuner_config cfg = {};
u32 freq;
int i;
cfg.fe = dvb->fe[n];
cfg.mock_power_up_delay_msec = mock_power_up_delay_msec;
cfg.mock_tune_delay_msec = mock_tune_delay_msec;
/* TODO: check if the frequencies are at a valid range */
memcpy(cfg.vidtv_valid_dvb_t_freqs,
vidtv_valid_dvb_t_freqs,
sizeof(vidtv_valid_dvb_t_freqs));
@ -349,9 +359,20 @@ static int vidtv_bridge_probe_tuner(struct vidtv_dvb *dvb, u32 n)
vidtv_valid_dvb_c_freqs,
sizeof(vidtv_valid_dvb_c_freqs));
memcpy(cfg.vidtv_valid_dvb_s_freqs,
vidtv_valid_dvb_s_freqs,
sizeof(vidtv_valid_dvb_s_freqs));
/*
* Convert Satellite frequencies from Ku-band in kHZ into S-band
* frequencies in Hz.
*/
for (i = 0; i < ARRAY_SIZE(vidtv_valid_dvb_s_freqs); i++) {
freq = vidtv_valid_dvb_s_freqs[i];
if (freq) {
if (freq < LNB_CUT_FREQUENCY)
freq = abs(freq - LNB_LOW_FREQ);
else
freq = abs(freq - LNB_HIGH_FREQ);
}
cfg.vidtv_valid_dvb_s_freqs[i] = freq;
}
cfg.max_frequency_shift_hz = max_frequency_shift_hz;