Skip to contentSkip to conversation

STV0910/STV6111 drivers, ddbridge CineS2 V7 support

PATCH Superseded Daniel Scheller 3 participants 14 messages Jun 24, 2017 – Jun 26, 2017

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover STV0910/STV6111 drivers, ddbridge CineS2 V7 support

From: Daniel Scheller <[email protected]>

For Linux 4.14.

This series adds drivers for the ST STV0910 DVB-S/S2 demodulator ICs and the ST STV6111 DVB-S/S2 tuners, and utilises them to enable ddbridge to support the current line of Digital Devices DVB-S/S2 hardware (e.g. Cine S2 V7/V7A adapters, DuoFlex S2 V4 addon modules and maybe more, with similar components).

The two new drivers have been picked up from Digital Devices' vendor- provided dddvb driver package, as of release 0.9.29. Permission to reuse (and mainline) them was formally granted by Ralph Metzler <[email protected]>.

Drivers have been cleaned up alot (formatting fixes, dead code removal, features depending on not-yet-available API changes removed). Checkpatch complaints left:

WARNING: please write a paragraph that describes the config symbol fully #39: FILE: drivers/media/dvb-frontends/Kconfig:31:
+config DVB_STV0910

Not sure what checkpatch demands, since a module description exists in Kconfig... Applies to the stv6111 aswell.

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #64:
new file mode 100644

See below.

WARNING: 'VALIDE' may be misspelled - perhaps 'VALID'? #3314: FILE: drivers/media/dvb-frontends/stv0910_regs.h:1467:
+#define FSTV0910_P2_NOSRAM_VALIDE 0xf30e0004

Picked from upstream. Since I'm not sure if this really is a mistake (maybe the hardware vendor really wants to name the reg like this?) so kept as-is.

Also, all uppercase writing an camel case are still there yet, and if you don't ultimately insist of having this changed (there are drivers all over the place which have uppercase vars), I'll prefer to keep it like it is at the moment to not diverge even more from upstream, that'll ease syncing later on that way. Else, I can change this ofc.

Patch 2 is a fix for an issue found while preparing this series for posting, and was in parallel submitted to the vendor's GIT repository.

Patch 8 eventually needs fixup (printk -> dev_*) wrt
https://patchwork.linuxtv.org/patch/42034/

Regarding MAINTAINERS and maintainership: I already offered to volunteer to regularly check for upstream updates and sync them to mainline, as outlined at
http://www.mail-archive.com/[email protected]/msg114469.html . If this qualifies for an entry in MAINTAINERS, then that one's missing. Please advise.

Mauro, I assume you're the one who reviews this (since these are new drivers). It'd be very great to have this in for 4.14 to tackle the ddbridge bump for 4.15.

Daniel Scheller (9):
[media] dvb-frontends: add ST STV0910 DVB-S/S2 demodulator frontend
driver
[media] dvb-frontends/stv0910: Fix possible buffer overflow [media] dvb-frontends/stv0910: add multistream (ISI) and PLS
capabilities
[media] dvb-frontends/stv0910: Fix signal strength reporting [media] dvb-frontends/stv0910: Add missing set_frontend fe-op [media] dvb-frontends: add ST STV6111 DVB-S/S2 tuner frontend driver [media] ddbridge: return stv09xx id in port_has_stv0900_aa() [media] ddbridge: support for CineS2 V7(A) and DuoFlex S2 V4 hardware [media] ddbridge: stv0910 single demod mode module option

 drivers/media/dvb-frontends/Kconfig        |   18 +
 drivers/media/dvb-frontends/Makefile       |    2 +
 drivers/media/dvb-frontends/stv0910.c      | 1765 +++++++++++
 drivers/media/dvb-frontends/stv0910.h      |   32 +
 drivers/media/dvb-frontends/stv0910_regs.h | 4759 ++++++++++++++++++++++++++++
 drivers/media/dvb-frontends/stv6111.c      |  675 ++++
 drivers/media/dvb-frontends/stv6111.h      |   20 +
 drivers/media/pci/ddbridge/Kconfig         |    4 +
 drivers/media/pci/ddbridge/ddbridge-core.c |  149 +-
 drivers/media/pci/ddbridge/ddbridge.h      |    2 +
 10 files changed, 7418 insertions(+), 8 deletions(-)
 create mode 100644 drivers/media/dvb-frontends/stv0910.c
 create mode 100644 drivers/media/dvb-frontends/stv0910.h
 create mode 100644 drivers/media/dvb-frontends/stv0910_regs.h
 create mode 100644 drivers/media/dvb-frontends/stv6111.c
 create mode 100644 drivers/media/dvb-frontends/stv6111.h
Signature · 1 line
2.13.0
#2 lore raw

PATCH 2/9 dvb-frontends/stv0910: Fix possible buffer overflow

From: Daniel Scheller <[email protected]>

Fixes smatch error:

drivers/media/dvb-frontends/stv0910.c:715 DVBS2_nBCH() error: buffer overflow 'nBCH[FECType]' 2 <= 28

Also, fixes the nBCH array table by adding the DUMMY_PLF element at the top to match the enums (table element order was off by one before).

Patch sent upstream aswell.

---
 drivers/media/dvb-frontends/stv0910.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/stv0910.c +2 -1
index 8cb4b30f3a81..a5eac1a3a048 100644
@@ -680,6 +680,7 @@ static int GetBitErrorRateS(struct stv *state, u32 *BERNumerator,
 static u32 DVBS2_nBCH(enum DVBS2_ModCod ModCod, enum DVBS2_FECType FECType)
 {
 	static u32 nBCH[][2] = {
+		{    0,     0}, /* DUMMY_PLF */
 		{16200,  3240}, /* QPSK_1_4, */
 		{21600,  5400}, /* QPSK_1_3, */
 		{25920,  6480}, /* QPSK_2_5, */
@@ -712,7 +713,7 @@ static u32 DVBS2_nBCH(enum DVBS2_ModCod ModCod, enum DVBS2_FECType FECType)
 
 	if (ModCod >= DVBS2_QPSK_1_4 &&
 	    ModCod <= DVBS2_32APSK_9_10 && FECType <= DVBS2_16K)
-		return nBCH[FECType][ModCod];
+		return nBCH[ModCod][FECType];
 	return 64800;
 }
 
Signature · 1 line
2.13.0
#3 lore raw

PATCH 3/9 dvb-frontends/stv0910: add multistream (ISI) and PLS capabilities

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

Implements stream_id filter and scrambling code setup in Start() and also sets FE_CAN_MULTISTREAM in frontend_ops. This enables the driver to properly receive and handle multistream transponders, functionality has been reported working fine by testers with access to such streams, in conjunction with VDR on the userspace side.

The code snippet originates from the original vendor's dddvb driver package and has been made working properly with the current in-kernel DVB core API.

---
 drivers/media/dvb-frontends/stv0910.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/media/dvb-frontends/stv0910.c +26 -6
index a5eac1a3a048..999ee6a8ea23 100644
@@ -124,9 +124,7 @@ struct stv {
 	int   isVCM;
 
 	u32   CurScramblingCode;
-	u32   ForceScramblingCode;
 	u32   ScramblingCode;
-	u32   DefaultInputStreamID;
 
 	u32   LastBERNumerator;
 	u32   LastBERDenominator;
@@ -972,6 +970,7 @@ static int Start(struct stv *state, struct dtv_frontend_properties *p)
 	s32 Freq;
 	u8  regDMDCFGMD;
 	u16 symb;
+	u32 ScramblingCode = 1;
 
 	if (p->symbol_rate < 100000 || p->symbol_rate > 70000000)
 		return -EINVAL;
@@ -985,6 +984,28 @@ static int Start(struct stv *state, struct dtv_frontend_properties *p)
 
 	init_search_param(state);
 
+	if (p->stream_id != NO_STREAM_ID_FILTER) {
+		/* Backwards compatibility to "crazy" API.
+		 * PRBS X root cannot be 0, so this should always work.
+		 */
+		if (p->stream_id & 0xffffff00)
+			ScramblingCode = p->stream_id >> 8;
+		write_reg(state, RSTV0910_P2_ISIENTRY + state->regoff,
+			  p->stream_id & 0xff);
+		write_reg(state, RSTV0910_P2_ISIBITENA + state->regoff,
+			  0xff);
+	}
+
+	if (ScramblingCode != state->CurScramblingCode) {
+		write_reg(state, RSTV0910_P2_PLROOT0 + state->regoff,
+			  ScramblingCode & 0xff);
+		write_reg(state, RSTV0910_P2_PLROOT1 + state->regoff,
+			  (ScramblingCode >> 8) & 0xff);
+		write_reg(state, RSTV0910_P2_PLROOT2 + state->regoff,
+			  (ScramblingCode >> 16) & 0x07);
+		state->CurScramblingCode = ScramblingCode;
+	}
+
 	if (p->symbol_rate <= 1000000) {  /* SR <=1Msps */
 		state->DemodTimeout = 3000;
 		state->FecTimeout = 2000;
@@ -1643,7 +1664,8 @@ static struct dvb_frontend_ops stv0910_ops = {
 		.caps			= FE_CAN_INVERSION_AUTO |
 					  FE_CAN_FEC_AUTO       |
 					  FE_CAN_QPSK           |
-					  FE_CAN_2G_MODULATION
+					  FE_CAN_2G_MODULATION  |
+					  FE_CAN_MULTISTREAM
 	},
 	.sleep				= sleep,
 	.release                        = release,
@@ -1687,9 +1709,7 @@ struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
 	state->SearchRange = 16000000;
 	state->DEMOD = 0x10;     /* Inversion : Auto with reset to 0 */
 	state->ReceiveMode   = Mode_None;
-	state->CurScramblingCode = (u32) -1;
-	state->ForceScramblingCode = (u32) -1;
-	state->DefaultInputStreamID = (u32) -1;
+	state->CurScramblingCode = (~0U);
 	state->single = cfg->single ? 1 : 0;
 
 	base = match_base(i2c, cfg->adr);
Signature · 1 line
2.13.0
#4 lore raw

PATCH 4/9 dvb-frontends/stv0910: Fix signal strength reporting

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

Original code at least has some signed/unsigned issues, resulting in values like 32dBm. Change signal strength readout to work without asking the attached tuner, and use a lookup table instead of log calc. Values reported appear plausible. Obsoletes the INTLOG10X100 calc macro.

---
 drivers/media/dvb-frontends/stv0910.c | 50 ++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 21 deletions(-)
drivers/media/dvb-frontends/stv0910.c +29 -21
index 999ee6a8ea23..c1875be01631 100644
@@ -31,8 +31,6 @@
 #include "stv0910.h"
 #include "stv0910_regs.h"
 
-#define INTLOG10X100(x) ((u32) (((u64) intlog10(x) * 100) >> 24))
-
 #define EXT_CLOCK   30000000
 #define TUNING_DELAY    200
 #define BER_SRC_S    0x20
@@ -140,7 +138,7 @@ struct SInitTable {
 
 struct SLookup {
 	s16  Value;
-	u16  RegValue;
+	u32  RegValue;
 };
 
 static inline int i2c_write(struct i2c_adapter *adap, u8 adr,
@@ -332,6 +330,25 @@ struct SLookup S2_SN_Lookup[] = {
 	{  510,    463  },  /*C/N=51.0dB*/
 };
 
+struct SLookup padc_lookup[] = {
+	{    0,  118000 }, /* PADC=+0dBm  */
+	{ -100,  93600  }, /* PADC=-1dBm  */
+	{ -200,  74500  }, /* PADC=-2dBm  */
+	{ -300,  59100  }, /* PADC=-3dBm  */
+	{ -400,  47000  }, /* PADC=-4dBm  */
+	{ -500,  37300  }, /* PADC=-5dBm  */
+	{ -600,  29650  }, /* PADC=-6dBm  */
+	{ -700,  23520  }, /* PADC=-7dBm  */
+	{ -900,  14850  }, /* PADC=-9dBm  */
+	{ -1100, 9380   }, /* PADC=-11dBm */
+	{ -1300, 5910   }, /* PADC=-13dBm */
+	{ -1500, 3730   }, /* PADC=-15dBm */
+	{ -1700, 2354   }, /* PADC=-17dBm */
+	{ -1900, 1485   }, /* PADC=-19dBm */
+	{ -2000, 1179   }, /* PADC=-20dBm */
+	{ -2100, 1000   }, /* PADC=-21dBm */
+};
+
 /*********************************************************************
  * Tracking carrier loop carrier QPSK 1/4 to 8PSK 9/10 long Frame
  *********************************************************************/
@@ -572,7 +589,7 @@ static int TrackingOptimization(struct stv *state)
 }
 
 static s32 TableLookup(struct SLookup *Table,
-		       int TableSize, u16 RegValue)
+		       int TableSize, u32 RegValue)
 {
 	s32 Value;
 	int imin = 0;
@@ -1300,17 +1317,18 @@ static int read_ber(struct dvb_frontend *fe, u32 *ber, u32 *n, u32 *d)
 	return 0;
 }
 
-static int read_signal_strength(struct dvb_frontend *fe, u16 *strength)
+static int read_signal_strength(struct dvb_frontend *fe, s64 *strength)
 {
 	struct stv *state = fe->demodulator_priv;
 	u8 Reg[2];
-	s32 bbgain;
+	u16 agc;
+	s32 padc;
 	s32 Power = 0;
 	int i;
 
 	read_regs(state, RSTV0910_P2_AGCIQIN1 + state->regoff, Reg, 2);
 
-	*strength = (((u32) Reg[0]) << 8) | Reg[1];
+	agc = (((u32) Reg[0]) << 8) | Reg[1];
 
 	for (i = 0; i < 5; i += 1) {
 		read_regs(state, RSTV0910_P2_POWERI + state->regoff, Reg, 2);
@@ -1320,20 +1338,9 @@ static int read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 	}
 	Power /= 5;
 
-	bbgain = (465 - INTLOG10X100(Power)) * 10;
-
-	if (fe->ops.tuner_ops.get_rf_strength)
-		fe->ops.tuner_ops.get_rf_strength(fe, strength);
-	else
-		*strength = 0;
-
-	if (bbgain < (s32) *strength)
-		*strength -= bbgain;
-	else
-		*strength = 0;
+	padc = TableLookup(padc_lookup, ARRAY_SIZE(padc_lookup), Power) + 352;
 
-	if (*strength > 0)
-		*strength = 10 * (s64) (s16) *strength - 108750;
+	*strength = (padc - agc);
 
 	return 0;
 }
@@ -1463,7 +1470,8 @@ static int get_frontend(struct dvb_frontend *fe,
 {
 	struct stv *state = fe->demodulator_priv;
 	enum fe_status status;
-	u16 snr = 0, strength = 0;
+	u16 snr = 0;
+	s64 strength = 0;
 	u32 ber = 0, bernom = 0, berdenom = 0;
 	u8 tmp;
 
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/9 dvb-frontends: add ST STV0910 DVB-S/S2 demodulator frontend driver

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

This adds a multi frontend driver for the ST STV0910 DVB-S/S2 demodulator frontends. The driver code originates from the Digital Devices' dddvb vendor driver package as of version 0.9.29, and has been cleaned up from core API usage which isn't supported yet in the kernel, and additionally all obvious style issues have been resolved. Any camel case that's still in it has been intenionally left intact so any changes (features, fixes and such) can be brought to the in-kernel driver more easily, and results from a shared code base utilised by the vendor.

Permission to reuse and mainline the driver code was formally granted by Ralph Metzler <[email protected]>.

---
 drivers/media/dvb-frontends/Kconfig        |    9 +
 drivers/media/dvb-frontends/Makefile       |    1 +
 drivers/media/dvb-frontends/stv0910.c      | 1735 ++++++++++
 drivers/media/dvb-frontends/stv0910.h      |   32 +
 drivers/media/dvb-frontends/stv0910_regs.h | 4759 ++++++++++++++++++++++++++++
 5 files changed, 6536 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/stv0910.c
 create mode 100644 drivers/media/dvb-frontends/stv0910.h
 create mode 100644 drivers/media/dvb-frontends/stv0910_regs.h
drivers/media/dvb-frontends/Kconfig +9 -0
index 3a260b82b3e8..773de5e264e3 100644
@@ -28,6 +28,15 @@ config DVB_STV090x
 	  DVB-S/S2/DSS Multistandard Professional/Broadcast demodulators.
 	  Say Y when you want to support these frontends.
 
+config DVB_STV0910
+	tristate "STV0910 based"
+	depends on DVB_CORE && I2C
+	default m if !MEDIA_SUBDRV_AUTOSELECT
+	help
+	  ST STV0910 DVB-S/S2 demodulator driver.
+
+	  Say Y when you want to support these frontends.
+
 config DVB_STV6110x
 	tristate "STV6110/(A) based tuners"
 	depends on DVB_CORE && I2C
drivers/media/dvb-frontends/Makefile +1 -0
index 3fccaf34ef52..c302b2d07499 100644
@@ -110,6 +110,7 @@ obj-$(CONFIG_DVB_CXD2820R) += cxd2820r.o
 obj-$(CONFIG_DVB_CXD2841ER) += cxd2841er.o
 obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
+obj-$(CONFIG_DVB_STV0910) += stv0910.o
 obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
 obj-$(CONFIG_DVB_SP2) += sp2.o
drivers/media/dvb-frontends/stv0910.c new file +1735 -0

1,735 lines not on this page · raw message

drivers/media/dvb-frontends/stv0910.h new file +32 -0
new file mode 100644
index 000000000000..e1ab6df7c805
@@ -0,0 +1,32 @@
+#ifndef _STV0910_H_
+#define _STV0910_H_
+
+#include <linux/types.h>
+#include <linux/i2c.h>
+
+struct stv0910_cfg {
+	u32 clk;
+	u8  adr;
+	u8  parallel;
+	u8  rptlvl;
+	u8  single;
+};
+
+#if IS_REACHABLE(CONFIG_DVB_STV0910)
+
+extern struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
+					   struct stv0910_cfg *cfg, int nr);
+
+#else
+
+static inline struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
+						  struct stv0910_cfg *cfg,
+						  int nr)
+{
+	pr_warn("%s: driver disabled by Kconfig\n", __func__);
+	return NULL;
+}
+
+#endif /* CONFIG_DVB_STV0910 */
+
+#endif /* _STV0910_H_ */
drivers/media/dvb-frontends/stv0910_regs.h new file +4759 -0

1,211 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.13.0

Part of the diff is not shown here. View the raw message.

#9 lore raw

PATCH 5/9 dvb-frontends/stv0910: Add missing set_frontend fe-op

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

This was missing from the frontend_ops.

---
 drivers/media/dvb-frontends/stv0910.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/dvb-frontends/stv0910.c +1 -0
index c1875be01631..d45c73a88dfb 100644
@@ -1678,6 +1678,7 @@ static struct dvb_frontend_ops stv0910_ops = {
 	.sleep				= sleep,
 	.release                        = release,
 	.i2c_gate_ctrl                  = gate_ctrl,
+	.set_frontend			= set_parameters,
 	.get_frontend_algo              = get_algo,
 	.get_frontend                   = get_frontend,
 	.tune                           = tune,
Signature · 1 line
2.13.0
#10 lore raw

PATCH 6/9 dvb-frontends: add ST STV6111 DVB-S/S2 tuner frontend driver

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

This adds a frontend driver for the ST STV6111 DVB-S/S2 tuners. Like the stv0910 demod frontend driver, this driver originates from the Digital Devices' dddvb vendor driver package as of version 0.9.29, and was cleaned up aswell. No functionality had to be removed though. For the same maintainability reasons, any camel case has been left intact so merges between upstream and in-kernel can be done easier.

Permission to reuse and mainline the driver code was formally granted by Ralph Metzler <[email protected]>.

---
 drivers/media/dvb-frontends/Kconfig   |   9 +
 drivers/media/dvb-frontends/Makefile  |   1 +
 drivers/media/dvb-frontends/stv6111.c | 675 ++++++++++++++++++++++++++++++++++
 drivers/media/dvb-frontends/stv6111.h |  20 +
 4 files changed, 705 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/stv6111.c
 create mode 100644 drivers/media/dvb-frontends/stv6111.h
drivers/media/dvb-frontends/Kconfig +9 -0
index 773de5e264e3..d2d3160abdf7 100644
@@ -44,6 +44,15 @@ config DVB_STV6110x
 	help
 	  A Silicon tuner that supports DVB-S and DVB-S2 modes
 
+config DVB_STV6111
+	tristate "STV6111 based tuners"
+	depends on DVB_CORE && I2C
+	default m if !MEDIA_SUBDRV_AUTOSELECT
+	help
+	  A Silicon tuner that supports DVB-S and DVB-S2 modes
+
+	  Say Y when you want to support these frontends.
+
 config DVB_M88DS3103
 	tristate "Montage Technology M88DS3103"
 	depends on DVB_CORE && I2C && I2C_MUX
drivers/media/dvb-frontends/Makefile +1 -0
index c302b2d07499..e8bf1d873485 100644
@@ -111,6 +111,7 @@ obj-$(CONFIG_DVB_CXD2841ER) += cxd2841er.o
 obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
 obj-$(CONFIG_DVB_STV0910) += stv0910.o
+obj-$(CONFIG_DVB_STV6111) += stv6111.o
 obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
 obj-$(CONFIG_DVB_SP2) += sp2.o
drivers/media/dvb-frontends/stv6111.c new file +675 -0

675 lines not on this page · raw message

drivers/media/dvb-frontends/stv6111.h new file +20 -0
new file mode 100644
index 000000000000..066dd70c9426
@@ -0,0 +1,20 @@
+#ifndef _STV6111_H_
+#define _STV6111_H_
+
+#if IS_REACHABLE(CONFIG_DVB_STV6111)
+
+extern struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe,
+				struct i2c_adapter *i2c, u8 adr);
+
+#else
+
+static inline struct dvb_frontend *stv6111_attach(struct dvb_frontend *fe,
+				struct i2c_adapter *i2c, u8 adr)
+{
+	pr_warn("%s: Driver disabled by Kconfig\n", __func__);
+	return NULL;
+}
+
+#endif /* CONFIG_DVB_STV6111 */
+
+#endif /* _STV6111_H_ */
Signature · 1 line
2.13.0
#11 lore raw

PATCH 7/9 ddbridge: return stv09xx id in port_has_stv0900_aa()

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

The returned value is required for further evaluation of the exact demodulator chip (stv090x or stv0910).

---
 drivers/media/pci/ddbridge/ddbridge-core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/pci/ddbridge/ddbridge-core.c +4 -5
index 9420479bee9a..8c8cea9602de 100644
@@ -1452,10 +1452,9 @@ static int port_has_stv0900(struct ddb_port *port)
 	return 1;
 }
 
-static int port_has_stv0900_aa(struct ddb_port *port)
+static int port_has_stv0900_aa(struct ddb_port *port, u8 *id)
 {
-	u8 val;
-	if (i2c_read_reg16(&port->i2c->adap, 0x68, 0xf100, &val) < 0)
+	if (i2c_read_reg16(&port->i2c->adap, 0x68, 0xf100, id) < 0)
 		return 0;
 	return 1;
 }
@@ -1502,7 +1501,7 @@ static void ddb_port_probe(struct ddb_port *port)
 {
 	struct ddb *dev = port->dev;
 	char *modname = "NO MODULE";
-	u8 xo2_type, xo2_id, cxd_id;
+	u8 xo2_type, xo2_id, cxd_id, stv_id;
 
 	port->class = DDB_PORT_NONE;
 
@@ -1594,7 +1593,7 @@ static void ddb_port_probe(struct ddb_port *port)
 		port->class = DDB_PORT_TUNER;
 		port->type = DDB_TUNER_DVBS_ST;
 		ddbwritel(I2C_SPEED_100, port->i2c->regs + I2C_TIMING);
-	} else if (port_has_stv0900_aa(port)) {
+	} else if (port_has_stv0900_aa(port, &stv_id)) {
 		modname = "DUAL DVB-S2";
 		port->class = DDB_PORT_TUNER;
 		port->type = DDB_TUNER_DVBS_ST_AA;
Signature · 1 line
2.13.0
#12 lore raw

PATCH 8/9 ddbridge: support for CineS2 V7(A) and DuoFlex S2 V4 hardware

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

This adds all required glue code to support - in conjunction with the new stv0910 and stv6111 demod/tuner drivers and additionally the lnbh25 LNB controller driver - all current DVB-S/S2 hardware (bridges and flex modules) from Digital Devices like the DD CineS2 V7 and V7A, current S2 V4 DuoFlex modules, and probably all upcoming devices based on this STV0910/STV6111/LNBH25 hardware stack.

---
 drivers/media/pci/ddbridge/Kconfig         |   4 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 133 ++++++++++++++++++++++++++++-
 drivers/media/pci/ddbridge/ddbridge.h      |   2 +
 3 files changed, 136 insertions(+), 3 deletions(-)
drivers/media/pci/ddbridge/Kconfig +4 -0
index ffed78c2ffb4..c79a58fa5fc3 100644
@@ -8,6 +8,9 @@ config DVB_DDBRIDGE
 	select DVB_TDA18271C2DD if MEDIA_SUBDRV_AUTOSELECT
 	select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT
 	select DVB_CXD2841ER if MEDIA_SUBDRV_AUTOSELECT
+	select DVB_STV0910 if MEDIA_SUBDRV_AUTOSELECT
+	select DVB_STV6111 if MEDIA_SUBDRV_AUTOSELECT
+	select DVB_LNBH25 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
 	---help---
 	  Support for cards with the Digital Devices PCI express bridge:
@@ -20,5 +23,6 @@ config DVB_DDBRIDGE
 	  - CineCTv6 and DuoFlex CT (STV0367-based)
 	  - CineCTv7 and DuoFlex CT2/C2T2/C2T2I (Sony CXD28xx-based)
 	  - MaxA8 series
+	  - CineS2 V7/V7A and DuoFlex S2 V4 (ST STV0910-based)
 
 	  Say Y if you own such a card and want to use it.
drivers/media/pci/ddbridge/ddbridge-core.c +130 -3

175 lines not on this page · raw message

drivers/media/pci/ddbridge/ddbridge.h +2 -0
index 4a0e3283d646..4783a17175a8 100644
@@ -160,6 +160,8 @@ struct ddb_port {
 #define DDB_TUNER_DVBCT2_SONY_P		7
 #define DDB_TUNER_DVBC2T2_SONY_P	8
 #define DDB_TUNER_ISDBT_SONY_P		9
+#define DDB_TUNER_DVBS_STV0910_P	10
+#define DDB_TUNER_DVBS_STV0910_PR	14
 #define DDB_TUNER_DVBC2T2I_SONY_P	15
 #define DDB_TUNER_DVBCT_TR		16
 #define DDB_TUNER_DVBCT_ST		17
Signature · 1 line
2.13.0
#13 lore raw

PATCH 9/9 ddbridge: stv0910 single demod mode module option

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

Adds a stv0910_single modparm which, when set, configures the stv0910 to run in single demodulator mode, currently intended for high bit rate testing.

---
 drivers/media/pci/ddbridge/ddbridge-core.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/media/pci/ddbridge/ddbridge-core.c +7 -0
index 45130fec392a..6ea429b16550 100644
@@ -51,6 +51,10 @@ static int xo2_speed = 2;
 module_param(xo2_speed, int, 0444);
 MODULE_PARM_DESC(xo2_speed, "default transfer speed for xo2 based duoflex, 0=55,1=75,2=90,3=104 MBit/s, default=2, use attribute to change for individual cards");
 
+static int stv0910_single;
+module_param(stv0910_single, int, 0444);
+MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 /* MSI had problems with lost interrupts, fixed but needs testing */
@@ -917,6 +921,9 @@ static int demod_attach_stv0910(struct ddb_input *input, int type)
 	struct stv0910_cfg cfg = stv0910_p;
 	struct lnbh25_config lnbcfg = lnbh25_cfg;
 
+	if (stv0910_single)
+		cfg.single = 1;
+
 	if (type)
 		cfg.parallel = 2;
 	input->fe = dvb_attach(stv0910_attach, i2c, &cfg, (input->nr & 1));
Signature · 1 line
2.13.0
#5 lore raw

PATCH 4/9 dvb-frontends/stv0910: Fix signal strength reporting

In reply to Daniel Scheller
Quoted 4 lines · Daniel Scheller

From: Daniel Scheller <[email protected]>

Original code at least has some signed/unsigned issues, resulting in values like 32dBm.

I will look into that.

Quoted 2 lines

Change signal strength readout to work without asking
the attached tuner, and use a lookup table instead of log calc. Values

How can you determine the exact strength without knowing what the tuner did? At least the stv6111 does its own AGC which has to be added.

Quoted 18 lines
drivers/media/dvb-frontends/stv0910.c +18 -0
+struct SLookup padc_lookup[] = {
+	{    0,  118000 }, /* PADC=+0dBm  */
+	{ -100,  93600  }, /* PADC=-1dBm  */
+	{ -200,  74500  }, /* PADC=-2dBm  */
+	{ -300,  59100  }, /* PADC=-3dBm  */
+	{ -400,  47000  }, /* PADC=-4dBm  */
+	{ -500,  37300  }, /* PADC=-5dBm  */
+	{ -600,  29650  }, /* PADC=-6dBm  */
+	{ -700,  23520  }, /* PADC=-7dBm  */
+	{ -900,  14850  }, /* PADC=-9dBm  */
+	{ -1100, 9380   }, /* PADC=-11dBm */
+	{ -1300, 5910   }, /* PADC=-13dBm */
+	{ -1500, 3730   }, /* PADC=-15dBm */
+	{ -1700, 2354   }, /* PADC=-17dBm */
+	{ -1900, 1485   }, /* PADC=-19dBm */
+	{ -2000, 1179   }, /* PADC=-20dBm */
+	{ -2100, 1000   }, /* PADC=-21dBm */
+};

...

drivers/media/dvb-frontends/stv0910.c static int read_signal_strength(struct dvb_frontend *fe, u16 *strength) · line 1341

Quoted 6 lines
drivers/media/dvb-frontends/stv0910.c +1 -4
-	if (bbgain < (s32) *strength)
-		*strength -= bbgain;
-	else
-		*strength = 0;
+	padc = TableLookup(padc_lookup, ARRAY_SIZE(padc_lookup), Power) + 352;

Where does the padc_lookup table come from?
I saw it before in CrazyCat github tree.
Is he or you the original source/author or somebody else?

Regards,
Ralph

#6 lore raw

Re: [PATCH 4/9] [media] dvb-frontends/stv0910: Fix signal strength reporting

Em Mon, 26 Jun 2017 10:55:34 +0200
Ralph Metzler <[email protected]> escreveu:

Quoted 6 lines
Quoted 4 lines · Daniel Scheller

From: Daniel Scheller <[email protected]>

Original code at least has some signed/unsigned issues, resulting in values like 32dBm.

Quoted 7 lines

I will look into that.

Quoted 2 lines

Change signal strength readout to work without asking
the attached tuner, and use a lookup table instead of log calc. Values

How can you determine the exact strength without knowing what the tuner did? At least the stv6111 does its own AGC which has to be added.

I remember I had to solve this issue on some other driver[1][2][3]. What I did was to get the AGC gain from the tuner using a callback, then I added it to the main gain.

[1] https://www.spinics.net/lists/linux-media/msg101836.html
[2] https://www.spinics.net/lists/linux-media/msg101838.html
[3] https://www.spinics.net/lists/linux-media/msg101842.html

I don't remember why it was not merged upstream, though. Perhaps because I was in doubt about reporting it as "rf_attenuation" or as "agc gain".

Anyway, with something like that, any demod could check for such callback. If defined, add it to its AGC own gain, in order to get the total AGC gain.

Quoted 32 lines
Quoted 18 lines
drivers/media/dvb-frontends/stv0910.c +18 -0
+struct SLookup padc_lookup[] = {
+	{    0,  118000 }, /* PADC=+0dBm  */
+	{ -100,  93600  }, /* PADC=-1dBm  */
+	{ -200,  74500  }, /* PADC=-2dBm  */
+	{ -300,  59100  }, /* PADC=-3dBm  */
+	{ -400,  47000  }, /* PADC=-4dBm  */
+	{ -500,  37300  }, /* PADC=-5dBm  */
+	{ -600,  29650  }, /* PADC=-6dBm  */
+	{ -700,  23520  }, /* PADC=-7dBm  */
+	{ -900,  14850  }, /* PADC=-9dBm  */
+	{ -1100, 9380   }, /* PADC=-11dBm */
+	{ -1300, 5910   }, /* PADC=-13dBm */
+	{ -1500, 3730   }, /* PADC=-15dBm */
+	{ -1700, 2354   }, /* PADC=-17dBm */
+	{ -1900, 1485   }, /* PADC=-19dBm */
+	{ -2000, 1179   }, /* PADC=-20dBm */
+	{ -2100, 1000   }, /* PADC=-21dBm */
+};  

...

drivers/media/dvb-frontends/stv0910.c static int read_signal_strength(struct dvb_frontend *fe, u16 *strength) · line 1341

Quoted 6 lines
drivers/media/dvb-frontends/stv0910.c +1 -4
-	if (bbgain < (s32) *strength)
-		*strength -= bbgain;
-	else
-		*strength = 0;
+	padc = TableLookup(padc_lookup, ARRAY_SIZE(padc_lookup), Power) + 352;

Where does the padc_lookup table come from?
I saw it before in CrazyCat github tree.
Is he or you the original source/author or somebody else?

Quoted 2 lines

Regards,
Ralph

Thanks,
Mauro

#7 lore raw

Re: [PATCH 4/9] [media] dvb-frontends/stv0910: Fix signal strength reporting

Quoted 25 lines · Mauro Carvalho Chehab

Em Mon, 26 Jun 2017 10:55:34 +0200
Ralph Metzler <[email protected]> escreveu:

Quoted 6 lines
Quoted 4 lines · Daniel Scheller

From: Daniel Scheller <[email protected]>

Original code at least has some signed/unsigned issues, resulting in values like 32dBm.

Quoted 7 lines

I will look into that.

Quoted 2 lines

Change signal strength readout to work without asking
the attached tuner, and use a lookup table instead of log calc. Values

How can you determine the exact strength without knowing what the tuner did? At least the stv6111 does its own AGC which has to be added.

I remember I had to solve this issue on some other driver[1][2][3]. What I did was to get the AGC gain from the tuner using a callback, then I added it to the main gain.

[1] https://www.spinics.net/lists/linux-media/msg101836.html
[2] https://www.spinics.net/lists/linux-media/msg101838.html
[3] https://www.spinics.net/lists/linux-media/msg101842.html

Quoted 6 lines

I don't remember why it was not merged upstream, though. Perhaps because I was in doubt about reporting it as "rf_attenuation" or as "agc gain".

Anyway, with something like that, any demod could check for such callback. If defined, add it to its AGC own gain, in order to get the total AGC gain.

I misused get_rf_strength for this in my versions of stv6111.c/stv0910.c. But get_rf_attenuation would be exactly what we need.

Daniel now removed the get_rf_strength() call from stv0910.c and ignores the correction from the tuner. That was what I was commenting on.

Regards,
Ralph

#8 lore raw

Re: [PATCH 4/9] [media] dvb-frontends/stv0910: Fix signal strength reporting

In reply to Ralph Metzler

Am Mon, 26 Jun 2017 10:55:34 +0200
schrieb Ralph Metzler <[email protected]>:

Quoted 8 lines
Quoted 4 lines · Daniel Scheller

From: Daniel Scheller <[email protected]>

Original code at least has some signed/unsigned issues, resulting in values like 32dBm.

I will look into that.

Quoted 7 lines
Quoted 3 lines

Change signal strength readout to work without asking the attached tuner, and use a lookup table instead of log calc. Values

How can you determine the exact strength without knowing what the tuner did? At least the stv6111 does its own AGC which has to be added.

Good to know. Though, from what I gathered, a lot of demod drivers are made this way, e.g. read out the AGC, do some math and have a signal strength as result. If there are ways to do this better and/or accurately, then by all means lets do this :)

Re the 32dBm, this is from a user who reported even four different values on the same coax cable (as he claimed). A MaxS8 and some measuring gear reported something around -25dBm. With the stv0910, the initial port from dddvb to the kernel reported those 32dBm, "the other driver" (suspect he meant dddvb but he wasn't exact in what that "other driver" was) did report -9dBm, and this changed variant reported around -30dBm, which seems plausible wrt the MaxS8 and his gauge.

Quoted 19 lines
Quoted 18 lines
drivers/media/dvb-frontends/stv0910.c +18 -0
+struct SLookup padc_lookup[] = {
+	{    0,  118000 }, /* PADC=+0dBm  */
+	{ -100,  93600  }, /* PADC=-1dBm  */
+	{ -200,  74500  }, /* PADC=-2dBm  */
+	{ -300,  59100  }, /* PADC=-3dBm  */
+	{ -400,  47000  }, /* PADC=-4dBm  */
+	{ -500,  37300  }, /* PADC=-5dBm  */
+	{ -600,  29650  }, /* PADC=-6dBm  */
+	{ -700,  23520  }, /* PADC=-7dBm  */
+	{ -900,  14850  }, /* PADC=-9dBm  */
+	{ -1100, 9380   }, /* PADC=-11dBm */
+	{ -1300, 5910   }, /* PADC=-13dBm */
+	{ -1500, 3730   }, /* PADC=-15dBm */
+	{ -1700, 2354   }, /* PADC=-17dBm */
+	{ -1900, 1485   }, /* PADC=-19dBm */
+	{ -2000, 1179   }, /* PADC=-20dBm */
+	{ -2100, 1000   }, /* PADC=-21dBm */
+};  

...

Quoted 11 lines
Quoted 6 lines
drivers/media/dvb-frontends/stv0910.c +1 -4
-	if (bbgain < (s32) *strength)
-		*strength -= bbgain;
-	else
-		*strength = 0;
+	padc = TableLookup(padc_lookup, ARRAY_SIZE(padc_lookup),

Power) + 352;

Where does the padc_lookup table come from?
I saw it before in CrazyCat github tree.
Is he or you the original source/author or somebody else?

Yes, this is picked from CrazyCat's GIT [1], more precisely, from the commit at [2], which imports an already modified version of your driver code, hidden behind the message "STV6120 tuner driver" (stv0910 is part of that commit). Honestly, no idea if he is the actual author of the table plus the math.

As initially mentioned, if we can fix this and do it the real proper way, let's do this and drop this patch, but this needs your help.

Best regards,
Daniel Scheller

[1] https://github.com/crazycat69/linux_media
[2]
https://github.com/crazycat69/linux_media/commit/9099babc397bb8bd9d0e33f39156643487378768

Signature · 1 line
https://github.com/herrnst