linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] vidtv: fix DVB-S/S2 simulation
@ 2020-09-15  7:22 Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 1/3] media: vidtv: add DiSEqC dummy ops Mauro Carvalho Chehab
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2020-09-15  7:22 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Daniel W. S. Almeida,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Add dummy functions to simulate a DisEqC , and fix the tuning logic,
in order to take a LNBf into account.

Mauro Carvalho Chehab (3):
  media: vidtv: add DiSEqC dummy ops
  media: vidtv: fix DVB-S/S2 tuning logic
  media: vidtv.rst: update it to better describe the frequencies

 .../driver-api/media/drivers/vidtv.rst        | 14 ++++++--
 .../media/test-drivers/vidtv/vidtv_bridge.c   | 35 +++++++++++++++----
 .../media/test-drivers/vidtv/vidtv_demod.c    | 33 +++++++++++++++--
 3 files changed, 70 insertions(+), 12 deletions(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] media: vidtv: add DiSEqC dummy ops
  2020-09-15  7:22 [PATCH 0/3] vidtv: fix DVB-S/S2 simulation Mauro Carvalho Chehab
@ 2020-09-15  7:22 ` Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 2/3] media: vidtv: fix DVB-S/S2 tuning logic Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 3/3] media: vidtv.rst: update it to better describe the frequencies Mauro Carvalho Chehab
  2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2020-09-15  7:22 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Daniel W. S. Almeida,
	Mauro Carvalho Chehab, linux-kernel, linux-media

Those are needed for real applications to work with Satellite
systems.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 .../media/test-drivers/vidtv/vidtv_demod.c    | 33 +++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/media/test-drivers/vidtv/vidtv_demod.c b/drivers/media/test-drivers/vidtv/vidtv_demod.c
index c825842758f0..8afdfb369ed1 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_demod.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_demod.c
@@ -320,6 +320,32 @@ static int vidtv_demod_set_voltage(struct dvb_frontend *fe,
 	return 0;
 }
 
+/*
+ * NOTE:
+ * This is implemented here just to be used as an example for real
+ * demod drivers.
+ *
+ * Should only be implemented if the demod has support for DVB-S or DVB-S2
+ */
+static int vidtv_send_diseqc_msg(struct dvb_frontend *fe,
+				 struct dvb_diseqc_master_cmd *cmd)
+{
+	return 0;
+}
+
+/*
+ * NOTE:
+ * This is implemented here just to be used as an example for real
+ * demod drivers.
+ *
+ * Should only be implemented if the demod has support for DVB-S or DVB-S2
+ */
+static int vidtv_diseqc_send_burst(struct dvb_frontend *fe,
+				   enum fe_sec_mini_cmd burst)
+{
+	return 0;
+}
+
 static void vidtv_demod_release(struct dvb_frontend *fe)
 {
 	struct vidtv_demod_state *state = fe->demodulator_priv;
@@ -376,8 +402,11 @@ static const struct dvb_frontend_ops vidtv_demod_ops = {
 	.read_signal_strength = vidtv_demod_read_signal_strength,
 
 	/* For DVB-S/S2 */
-	.set_voltage = vidtv_demod_set_voltage,
-	.set_tone    = vidtv_demod_set_tone,
+	.set_voltage		= vidtv_demod_set_voltage,
+	.set_tone		= vidtv_demod_set_tone,
+	.diseqc_send_master_cmd	= vidtv_send_diseqc_msg,
+	.diseqc_send_burst	= vidtv_diseqc_send_burst,
+
 };
 
 static const struct i2c_device_id vidtv_demod_i2c_id_table[] = {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] media: vidtv: fix DVB-S/S2 tuning logic
  2020-09-15  7:22 [PATCH 0/3] vidtv: fix DVB-S/S2 simulation Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 1/3] media: vidtv: add DiSEqC dummy ops Mauro Carvalho Chehab
@ 2020-09-15  7:22 ` Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 3/3] media: vidtv.rst: update it to better describe the frequencies Mauro Carvalho Chehab
  2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2020-09-15  7:22 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Daniel W. S. Almeida,
	Mauro Carvalho Chehab, linux-kernel, linux-media

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>
---
 .../media/test-drivers/vidtv/vidtv_bridge.c   | 35 +++++++++++++++----
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/drivers/media/test-drivers/vidtv/vidtv_bridge.c b/drivers/media/test-drivers/vidtv/vidtv_bridge.c
index 108e7937e9c1..fe4e496acc34 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_bridge.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_bridge.c
@@ -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;
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] media: vidtv.rst: update it to better describe the frequencies
  2020-09-15  7:22 [PATCH 0/3] vidtv: fix DVB-S/S2 simulation Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 1/3] media: vidtv: add DiSEqC dummy ops Mauro Carvalho Chehab
  2020-09-15  7:22 ` [PATCH 2/3] media: vidtv: fix DVB-S/S2 tuning logic Mauro Carvalho Chehab
@ 2020-09-15  7:22 ` Mauro Carvalho Chehab
  2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2020-09-15  7:22 UTC (permalink / raw)
  Cc: Mauro Carvalho Chehab, Daniel W. S. Almeida,
	Mauro Carvalho Chehab, linux-kernel, linux-media

The virtual driver has now a minimal set of frequencies for a
single transponder to be found by each DVB standard.

Document it, and update related information about the
simulated LNBf.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 Documentation/driver-api/media/drivers/vidtv.rst | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Documentation/driver-api/media/drivers/vidtv.rst b/Documentation/driver-api/media/drivers/vidtv.rst
index c9f62fcfdd9b..65115448c52d 100644
--- a/Documentation/driver-api/media/drivers/vidtv.rst
+++ b/Documentation/driver-api/media/drivers/vidtv.rst
@@ -62,6 +62,14 @@ When compiled as a module, run::
 That's it! The bridge driver will initialize the tuner and demod drivers as
 part of its own initialization.
 
+By default, it will accept the following frequencies:
+
+	- 474 MHz for DVB-T/T2/C;
+	- 11,362 GHz for DVB-S/S2.
+
+For satellite systems, the driver simulates an universal extended
+LNBf, with frequencies at Ku-Band, ranging from 10.7 GHz to 12.75 GHz.
+
 You can optionally define some command-line arguments to vidtv.
 
 Command-line arguments to vidtv
@@ -86,13 +94,13 @@ mock_tune_delay_msec
 	Simulate a tune delay.  Default 0.
 
 vidtv_valid_dvb_t_freqs
-	Valid DVB-T frequencies to simulate.
+	Valid DVB-T frequencies to simulate, in Hz.
 
 vidtv_valid_dvb_c_freqs
-	Valid DVB-C frequencies to simulate.
+	Valid DVB-C frequencies to simulate, in Hz.
 
 vidtv_valid_dvb_s_freqs
-	Valid DVB-C frequencies to simulate.
+	Valid DVB-S/S2 frequencies to simulate at Ku-Band, in kHz.
 
 max_frequency_shift_hz,
 	Maximum shift in HZ allowed when tuning in a channel.
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-15  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15  7:22 [PATCH 0/3] vidtv: fix DVB-S/S2 simulation Mauro Carvalho Chehab
2020-09-15  7:22 ` [PATCH 1/3] media: vidtv: add DiSEqC dummy ops Mauro Carvalho Chehab
2020-09-15  7:22 ` [PATCH 2/3] media: vidtv: fix DVB-S/S2 tuning logic Mauro Carvalho Chehab
2020-09-15  7:22 ` [PATCH 3/3] media: vidtv.rst: update it to better describe the frequencies Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).