Skip to contentSkip to conversation

STV0910/STV6111 drivers, ddbridge CineS2 V7 support

PATCH In review Daniel Scheller 2 participants 13 messages Jul 3, 2017 – Jul 20, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover STV0910/STV6111 drivers, ddbridge CineS2 V7 support

From: Daniel Scheller <[email protected]>

For Linux 4.14.

This v3 is a fixup for the previously posted v2. Smatch and W=1 uncovered three additional issues in the stv6111 driver, see the v3 notes below. While at it, few things have been fixed in patch 1 (initial stv0910 driver). Sorry for the noise and the mail spam, will try harder to properly test things before posting next time... At least, we're clean of warnings (smatch and W=1) and bisect issues now.

Superseeds initial (v1) and v2 series.

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.

CamelCase and ALLCAPS are changed into kernel_kase. Patches have been proposed to the vendor driver package maintainers to keep things synced as much as possible.

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.

Adding myself to MAINTAINERS for stv0910 and stv6111 as I'll keep track of any upstream (vendor provided package) changes and propose them for mainline inclusion.

Tested-by's from Richard Scobie <[email protected]> added to the commit descriptions.

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. Of course awaiting review yet. I believe this v3 is at least cleaned up as much as possible, thus an even better merge candidate than v2 :-)

Changes from v2 to v3:
- Fixed three warnings in the stv6111 driver, uncovered by W=1 and another smatch run:
* in wait_for_call_done(), int status was redeclared to u8 status (due to the camelcase fixup), triggering a -Wtype-limits warning. Additional fix proposed to the vendor package maintainers aswell.
* removed variable "symb" from set_params() (fixes -Wunused-but-set- variable)
* added '#include "stv6111.h"', fixes -Wmissing-prototype for

     *stv6111_attach()

- Removed unused scrambling_code vars from patch 1
- Changed "return -1" to "return -EINVAL" in manage_matype_info()
- Add required fe.dtv_propcache vars/references to the dummy STR function, fixes bisect

Changes from v1 to v2:
- CamelCase and ALLCAPS changed to kernel_case
- Signal statistics acquisition refactored to comply with standards
- printk* and pr_* changed to dev_*
- Add myself to MAINTAINERS for stv0910 and stv6111

Daniel Scheller (10):
[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: Add demod-only 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 [media] MAINTAINERS: add entries for stv0910 and stv6111

 MAINTAINERS                                |   16 +
 drivers/media/dvb-frontends/Kconfig        |   18 +
 drivers/media/dvb-frontends/Makefile       |    2 +
 drivers/media/dvb-frontends/stv0910.c      | 1771 +++++++++++
 drivers/media/dvb-frontends/stv0910.h      |   32 +
 drivers/media/dvb-frontends/stv0910_regs.h | 4759 ++++++++++++++++++++++++++++
 drivers/media/dvb-frontends/stv6111.c      |  674 ++++
 drivers/media/dvb-frontends/stv6111.h      |   20 +
 drivers/media/pci/ddbridge/Kconfig         |    4 +
 drivers/media/pci/ddbridge/ddbridge-core.c |  151 +-
 drivers/media/pci/ddbridge/ddbridge.h      |    2 +
 11 files changed, 7441 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
#1 lore raw

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

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. All camel case and allcaps have been converted to kernel_case and lowercase. Patches have been sent to the vendor package maintainers to fix this aswell. Signal statistics acquisition has been refactored to comply with standards.

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      | 1702 ++++++++++
 drivers/media/dvb-frontends/stv0910.h      |   32 +
 drivers/media/dvb-frontends/stv0910_regs.h | 4759 ++++++++++++++++++++++++++++
 5 files changed, 6503 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 +1702 -0

1,702 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,244 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.

#2 lore raw

Re: [PATCH v3 01/10] [media] dvb-frontends: add ST STV0910 DVB-S/S2 demodulator frontend driver

Em Mon, 3 Jul 2017 19:20:54 +0200
Daniel Scheller <[email protected]> escreveu:

Quoted 389 lines

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. All camel case and allcaps have been converted to kernel_case and lowercase. Patches have been sent to the vendor package maintainers to fix this aswell. Signal statistics acquisition has been refactored to comply with standards.

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      | 1702 ++++++++++
 drivers/media/dvb-frontends/stv0910.h      |   32 +
 drivers/media/dvb-frontends/stv0910_regs.h | 4759 ++++++++++++++++++++++++++++
 5 files changed, 6503 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 +324 -0
new file mode 100644
index 000000000000..9dfcaf5e067f
@@ -0,0 +1,1702 @@
+/*
+ * Driver for the ST STV0910 DVB-S/S2 demodulator.
+ *
+ * Copyright (C) 2014-2015 Ralph Metzler <[email protected]>
+ *                         Marcus Metzler <[email protected]>
+ *                         developed for Digital Devices GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 only, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/firmware.h>
+#include <linux/i2c.h>
+#include <asm/div64.h>
+
+#include "dvb_math.h"
+#include "dvb_frontend.h"
+#include "stv0910.h"
+#include "stv0910_regs.h"
+
+#define EXT_CLOCK    30000000
+#define TUNING_DELAY 200
+#define BER_SRC_S    0x20
+#define BER_SRC_S2   0x20
+
+LIST_HEAD(stvlist);
+
+enum receive_mode { RCVMODE_NONE, RCVMODE_DVBS, RCVMODE_DVBS2, RCVMODE_AUTO };
+
+enum dvbs2_fectype { DVBS2_64K, DVBS2_16K };
+
+enum dvbs2_mod_cod {
+	DVBS2_DUMMY_PLF, DVBS2_QPSK_1_4, DVBS2_QPSK_1_3, DVBS2_QPSK_2_5,
+	DVBS2_QPSK_1_2, DVBS2_QPSK_3_5, DVBS2_QPSK_2_3,	DVBS2_QPSK_3_4,
+	DVBS2_QPSK_4_5,	DVBS2_QPSK_5_6,	DVBS2_QPSK_8_9,	DVBS2_QPSK_9_10,
+	DVBS2_8PSK_3_5,	DVBS2_8PSK_2_3,	DVBS2_8PSK_3_4,	DVBS2_8PSK_5_6,
+	DVBS2_8PSK_8_9,	DVBS2_8PSK_9_10, DVBS2_16APSK_2_3, DVBS2_16APSK_3_4,
+	DVBS2_16APSK_4_5, DVBS2_16APSK_5_6, DVBS2_16APSK_8_9, DVBS2_16APSK_9_10,
+	DVBS2_32APSK_3_4, DVBS2_32APSK_4_5, DVBS2_32APSK_5_6, DVBS2_32APSK_8_9,
+	DVBS2_32APSK_9_10
+};
+
+enum fe_stv0910_mod_cod {
+	FE_DUMMY_PLF, FE_QPSK_14, FE_QPSK_13, FE_QPSK_25,
+	FE_QPSK_12, FE_QPSK_35, FE_QPSK_23, FE_QPSK_34,
+	FE_QPSK_45, FE_QPSK_56, FE_QPSK_89, FE_QPSK_910,
+	FE_8PSK_35, FE_8PSK_23, FE_8PSK_34, FE_8PSK_56,
+	FE_8PSK_89, FE_8PSK_910, FE_16APSK_23, FE_16APSK_34,
+	FE_16APSK_45, FE_16APSK_56, FE_16APSK_89, FE_16APSK_910,
+	FE_32APSK_34, FE_32APSK_45, FE_32APSK_56, FE_32APSK_89,
+	FE_32APSK_910
+};
+
+enum fe_stv0910_roll_off { FE_SAT_35, FE_SAT_25, FE_SAT_20, FE_SAT_15 };
+
+static inline u32 muldiv32(u32 a, u32 b, u32 c)
+{
+	u64 tmp64;
+
+	tmp64 = (u64)a * (u64)b;
+	do_div(tmp64, c);
+
+	return (u32) tmp64;
+}
+
+struct stv_base {
+	struct list_head     stvlist;
+
+	u8                   adr;
+	struct i2c_adapter  *i2c;
+	struct mutex         i2c_lock;
+	struct mutex         reg_lock;
+	int                  count;
+
+	u32                  extclk;
+	u32                  mclk;
+};
+
+struct stv {
+	struct stv_base     *base;
+	struct dvb_frontend  fe;
+	int                  nr;
+	u16                  regoff;
+	u8                   i2crpt;
+	u8                   tscfgh;
+	u8                   tsgeneral;
+	u8                   tsspeed;
+	u8                   single;
+	unsigned long        tune_time;
+
+	s32                  search_range;
+	u32                  started;
+	u32                  demod_lock_time;
+	enum receive_mode    receive_mode;
+	u32                  demod_timeout;
+	u32                  fec_timeout;
+	u32                  first_time_lock;
+	u8                   demod_bits;
+	u32                  symbol_rate;
+
+	u8                       last_viterbi_rate;
+	enum fe_code_rate        puncture_rate;
+	enum fe_stv0910_mod_cod  mod_cod;
+	enum dvbs2_fectype       fectype;
+	u32                      pilots;
+	enum fe_stv0910_roll_off feroll_off;
+
+	int   is_standard_broadcast;
+	int   is_vcm;
+
+	u32   last_bernumerator;
+	u32   last_berdenominator;
+	u8    berscale;
+
+	u8    vth[6];
+};
+
+struct sinit_table {
+	u16  address;
+	u8   data;
+};
+
+struct slookup {
+	s16  value;
+	u16  reg_value;
+};
+
+static inline int i2c_write(struct i2c_adapter *adap, u8 adr,
+			    u8 *data, int len)
+{
+	struct i2c_msg msg = {.addr = adr, .flags = 0,
+			      .buf = data, .len = len};
+
+	if (i2c_transfer(adap, &msg, 1) != 1) {
+		dev_warn(&adap->dev, "i2c write error ([%02x] %04x: %02x)\n",
+			adr, (data[0] << 8) | data[1],
+			(len > 2 ? data[2] : 0));
+		return -EREMOTEIO;
+	}
+	return 0;
+}
+
+static int i2c_write_reg16(struct i2c_adapter *adap, u8 adr, u16 reg, u8 val)
+{
+	u8 msg[3] = {reg >> 8, reg & 0xff, val};
+
+	return i2c_write(adap, adr, msg, 3);
+}
+
+static int write_reg(struct stv *state, u16 reg, u8 val)
+{
+	return i2c_write_reg16(state->base->i2c, state->base->adr, reg, val);
+}
+
+static inline int i2c_read_regs16(struct i2c_adapter *adapter, u8 adr,
+				 u16 reg, u8 *val, int count)
+{
+	u8 msg[2] = {reg >> 8, reg & 0xff};
+	struct i2c_msg msgs[2] = {{.addr = adr, .flags = 0,
+				   .buf  = msg, .len   = 2},
+				  {.addr = adr, .flags = I2C_M_RD,
+				   .buf  = val, .len   = count } };
+
+	if (i2c_transfer(adapter, msgs, 2) != 2) {
+		dev_warn(&adapter->dev, "i2c read error ([%02x] %04x)\n",
+			adr, reg);
+		return -EREMOTEIO;
+	}
+	return 0;
+}
+
+static int read_reg(struct stv *state, u16 reg, u8 *val)
+{
+	return i2c_read_regs16(state->base->i2c, state->base->adr,
+		reg, val, 1);
+}
+
+static int read_regs(struct stv *state, u16 reg, u8 *val, int len)
+{
+	return i2c_read_regs16(state->base->i2c, state->base->adr,
+			       reg, val, len);
+}
+
+static int write_shared_reg(struct stv *state, u16 reg, u8 mask, u8 val)
+{
+	int status;
+	u8 tmp;
+
+	mutex_lock(&state->base->reg_lock);
+	status = read_reg(state, reg, &tmp);
+	if (!status)
+		status = write_reg(state, reg, (tmp & ~mask) | (val & mask));
+	mutex_unlock(&state->base->reg_lock);
+	return status;
+}
+
+struct slookup s1_sn_lookup[] = {
+	{   0,    9242  },  /*C/N=  0dB*/
+	{   5,    9105  },  /*C/N=0.5dB*/
+	{  10,    8950  },  /*C/N=1.0dB*/
+	{  15,    8780  },  /*C/N=1.5dB*/
+	{  20,    8566  },  /*C/N=2.0dB*/
+	{  25,    8366  },  /*C/N=2.5dB*/
+	{  30,    8146  },  /*C/N=3.0dB*/
+	{  35,    7908  },  /*C/N=3.5dB*/
+	{  40,    7666  },  /*C/N=4.0dB*/
+	{  45,    7405  },  /*C/N=4.5dB*/
+	{  50,    7136  },  /*C/N=5.0dB*/
+	{  55,    6861  },  /*C/N=5.5dB*/
+	{  60,    6576  },  /*C/N=6.0dB*/
+	{  65,    6330  },  /*C/N=6.5dB*/
+	{  70,    6048  },  /*C/N=7.0dB*/
+	{  75,    5768  },  /*C/N=7.5dB*/
+	{  80,    5492  },  /*C/N=8.0dB*/
+	{  85,    5224  },  /*C/N=8.5dB*/
+	{  90,    4959  },  /*C/N=9.0dB*/
+	{  95,    4709  },  /*C/N=9.5dB*/
+	{  100,   4467  },  /*C/N=10.0dB*/
+	{  105,   4236  },  /*C/N=10.5dB*/
+	{  110,   4013  },  /*C/N=11.0dB*/
+	{  115,   3800  },  /*C/N=11.5dB*/
+	{  120,   3598  },  /*C/N=12.0dB*/
+	{  125,   3406  },  /*C/N=12.5dB*/
+	{  130,   3225  },  /*C/N=13.0dB*/
+	{  135,   3052  },  /*C/N=13.5dB*/
+	{  140,   2889  },  /*C/N=14.0dB*/
+	{  145,   2733  },  /*C/N=14.5dB*/
+	{  150,   2587  },  /*C/N=15.0dB*/
+	{  160,   2318  },  /*C/N=16.0dB*/
+	{  170,   2077  },  /*C/N=17.0dB*/
+	{  180,   1862  },  /*C/N=18.0dB*/
+	{  190,   1670  },  /*C/N=19.0dB*/
+	{  200,   1499  },  /*C/N=20.0dB*/
+	{  210,   1347  },  /*C/N=21.0dB*/
+	{  220,   1213  },  /*C/N=22.0dB*/
+	{  230,   1095  },  /*C/N=23.0dB*/
+	{  240,    992  },  /*C/N=24.0dB*/
+	{  250,    900  },  /*C/N=25.0dB*/
+	{  260,    826  },  /*C/N=26.0dB*/
+	{  270,    758  },  /*C/N=27.0dB*/
+	{  280,    702  },  /*C/N=28.0dB*/
+	{  290,    653  },  /*C/N=29.0dB*/
+	{  300,    613  },  /*C/N=30.0dB*/
+	{  310,    579  },  /*C/N=31.0dB*/
+	{  320,    550  },  /*C/N=32.0dB*/
+	{  330,    526  },  /*C/N=33.0dB*/
+	{  350,    490  },  /*C/N=33.0dB*/
+	{  400,    445  },  /*C/N=40.0dB*/
+	{  450,    430  },  /*C/N=45.0dB*/
+	{  500,    426  },  /*C/N=50.0dB*/
+	{  510,    425  }   /*C/N=51.0dB*/
+};
+
+struct slookup s2_sn_lookup[] = {
+	{  -30,  13950  },  /*C/N=-2.5dB*/
+	{  -25,  13580  },  /*C/N=-2.5dB*/
+	{  -20,  13150  },  /*C/N=-2.0dB*/
+	{  -15,  12760  },  /*C/N=-1.5dB*/
+	{  -10,  12345  },  /*C/N=-1.0dB*/
+	{   -5,  11900  },  /*C/N=-0.5dB*/
+	{    0,  11520  },  /*C/N=   0dB*/
+	{    5,  11080  },  /*C/N= 0.5dB*/
+	{   10,  10630  },  /*C/N= 1.0dB*/
+	{   15,  10210  },  /*C/N= 1.5dB*/
+	{   20,   9790  },  /*C/N= 2.0dB*/
+	{   25,   9390  },  /*C/N= 2.5dB*/
+	{   30,   8970  },  /*C/N= 3.0dB*/
+	{   35,   8575  },  /*C/N= 3.5dB*/
+	{   40,   8180  },  /*C/N= 4.0dB*/
+	{   45,   7800  },  /*C/N= 4.5dB*/
+	{   50,   7430  },  /*C/N= 5.0dB*/
+	{   55,   7080  },  /*C/N= 5.5dB*/
+	{   60,   6720  },  /*C/N= 6.0dB*/
+	{   65,   6320  },  /*C/N= 6.5dB*/
+	{   70,   6060  },  /*C/N= 7.0dB*/
+	{   75,   5760  },  /*C/N= 7.5dB*/
+	{   80,   5480  },  /*C/N= 8.0dB*/
+	{   85,   5200  },  /*C/N= 8.5dB*/
+	{   90,   4930  },  /*C/N= 9.0dB*/
+	{   95,   4680  },  /*C/N= 9.5dB*/
+	{  100,   4425  },  /*C/N=10.0dB*/
+	{  105,   4210  },  /*C/N=10.5dB*/
+	{  110,   3980  },  /*C/N=11.0dB*/
+	{  115,   3765  },  /*C/N=11.5dB*/
+	{  120,   3570  },  /*C/N=12.0dB*/
+	{  125,   3315  },  /*C/N=12.5dB*/
+	{  130,   3140  },  /*C/N=13.0dB*/
+	{  135,   2980  },  /*C/N=13.5dB*/
+	{  140,   2820  },  /*C/N=14.0dB*/
+	{  145,   2670  },  /*C/N=14.5dB*/
+	{  150,   2535  },  /*C/N=15.0dB*/
+	{  160,   2270  },  /*C/N=16.0dB*/
+	{  170,   2035  },  /*C/N=17.0dB*/
+	{  180,   1825  },  /*C/N=18.0dB*/
+	{  190,   1650  },  /*C/N=19.0dB*/
+	{  200,   1485  },  /*C/N=20.0dB*/
+	{  210,   1340  },  /*C/N=21.0dB*/
+	{  220,   1212  },  /*C/N=22.0dB*/
+	{  230,   1100  },  /*C/N=23.0dB*/
+	{  240,   1000  },  /*C/N=24.0dB*/
+	{  250,    910  },  /*C/N=25.0dB*/
+	{  260,    836  },  /*C/N=26.0dB*/
+	{  270,    772  },  /*C/N=27.0dB*/
+	{  280,    718  },  /*C/N=28.0dB*/
+	{  290,    671  },  /*C/N=29.0dB*/
+	{  300,    635  },  /*C/N=30.0dB*/
+	{  310,    602  },  /*C/N=31.0dB*/
+	{  320,    575  },  /*C/N=32.0dB*/
+	{  330,    550  },  /*C/N=33.0dB*/
+	{  350,    517  },  /*C/N=35.0dB*/
+	{  400,    480  },  /*C/N=40.0dB*/
+	{  450,    466  },  /*C/N=45.0dB*/
+	{  500,    464  },  /*C/N=50.0dB*/

drivers/media/dvb-frontends/stv0910.c line 334

Quoted 10 lines
drivers/media/dvb-frontends/stv0910.c new file +10 -0
+	{  510,    463  },  /*C/N=51.0dB*/
+};
+
+/*********************************************************************
+ * Tracking carrier loop carrier QPSK 1/4 to 8PSK 9/10 long Frame
+ *********************************************************************/
+static u8 s2car_loop[] =	{
+	/* Modcod  2MPon 2MPoff 5MPon 5MPoff 10MPon 10MPoff
+	 * 20MPon 20MPoff 30MPon 30MPoff
+	 */

The right coding style for multi-line comments is:

	/*
	 * foo
	 * bar
	 */

I ended by merging this series, but please send a fixup patch when you have some time.

Btw, specially for new drivers, it could worth running checkpatch in scritct mode:

$ git diff 435945e08551|./scripts/checkpatch.pl --terse --strict
-:36: WARNING: please write a paragraph that describes the config symbol fully
-:52: WARNING: please write a paragraph that describes the config symbol fully
-:78: WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
-:156: CHECK: No space is necessary after a cast
-:164: CHECK: struct mutex definition without comment
-:165: CHECK: struct mutex definition without comment
-:231: CHECK: Alignment should match open parenthesis
-:251: CHECK: Alignment should match open parenthesis
-:261: CHECK: Alignment should match open parenthesis
-:558: CHECK: No space is necessary after a cast
-:559: CHECK: No space is necessary after a cast
-:560: CHECK: No space is necessary after a cast
-:561: CHECK: No space is necessary after a cast
-:563: CHECK: spaces preferred around that '<<' (ctx:VxV)
-:566: CHECK: No space is necessary after a cast
-:567: CHECK: No space is necessary after a cast
-:583: CHECK: No space is necessary after a cast
-:585: CHECK: No space is necessary after a cast
-:671: CHECK: Alignment should match open parenthesis
-:680: CHECK: braces {} should be used on all arms of this statement
-:684: CHECK: Unbalanced braces around else statement
-:685: CHECK: spaces preferred around that '-' (ctx:VxV)
-:688: CHECK: Alignment should match open parenthesis
-:734: CHECK: No space is necessary after a cast
-:740: CHECK: Alignment should match open parenthesis
-:754: CHECK: No space is necessary after a cast
-:755: CHECK: No space is necessary after a cast
-:815: CHECK: Alignment should match open parenthesis
-:827: CHECK: No space is necessary after a cast
-:830: CHECK: No space is necessary after a cast
-:831: CHECK: No space is necessary after a cast
-:849: CHECK: Alignment should match open parenthesis
-:1296: CHECK: Please don't use multiple blank lines
-:1358: CHECK: Alignment should match open parenthesis
-:1360: CHECK: No space is necessary after a cast
-:1377: CHECK: braces {} should be used on all arms of this statement
-:1380: CHECK: Unbalanced braces around else statement
-:1414: CHECK: No space is necessary after a cast
-:1418: CHECK: No space is necessary after a cast
-:1419: CHECK: No space is necessary after a cast
-:1578: CHECK: braces {} should be used on all arms of this statement
-:1580: CHECK: Unbalanced braces around else statement
-:1672: CHECK: Please don't use multiple blank lines
-:1794: CHECK: Prefer kzalloc(sizeof(*state)...) over kzalloc(sizeof(struct stv)...)
-:1815: CHECK: Prefer kzalloc(sizeof(*base)...) over kzalloc(sizeof(struct stv_base)...)
-:1828: CHECK: Alignment should match open parenthesis
-:1839: CHECK: Alignment should match open parenthesis
-:1876: CHECK: extern prototypes should be avoided in .h files
-:3364: WARNING: 'VALIDE' may be misspelled - perhaps 'VALID'?
-:4927: WARNING: 'VALIDE' may be misspelled - perhaps 'VALID'?
-:6963: CHECK: No space is necessary after a cast
-:7094: CHECK: spaces preferred around that '-' (ctx:VxV)
-:7097: CHECK: spaces preferred around that '-' (ctx:VxV)
-:7207: CHECK: braces {} should be used on all arms of this statement
-:7211: CHECK: Unbalanced braces around else statement
-:7212: CHECK: spaces preferred around that '-' (ctx:VxV)
-:7223: CHECK: No space is necessary after a cast
-:7225: CHECK: spaces preferred around that '/' (ctx:VxV)
-:7252: CHECK: Alignment should match open parenthesis
-:7256: CHECK: Alignment should match open parenthesis
-:7266: CHECK: Alignment should match open parenthesis
-:7271: CHECK: Alignment should match open parenthesis
-:7312: CHECK: Prefer kzalloc(sizeof(*state)...) over kzalloc(sizeof(struct stv)...)
-:7348: CHECK: extern prototypes should be avoided in .h files
-:7349: CHECK: Alignment should match open parenthesis
-:7354: CHECK: Alignment should match open parenthesis
-:7439: CHECK: Alignment should match open parenthesis
-:7564: CHECK: Alignment should match open parenthesis
total: 0 errors, 5 warnings, 63 checks, 7552 lines checked

Several of those warnings can be automatically fixed with:

./scripts/checkpatch.pl -f $(git diff 435945e08551|diffstat -p1 -l|grep -v MAINT) --strict --fix-inplace

But you need to review if the results are ok.

Regards,
Mauro

#3 lore raw

Re: [PATCH v3 01/10] [media] dvb-frontends: add ST STV0910 DVB-S/S2 demodulator frontend driver

Hi,

Am Thu, 20 Jul 2017 14:21:24 -0300
schrieb Mauro Carvalho Chehab <[email protected]>:

Quoted 8 lines

The right coding style for multi-line comments is:

	/*
	 * foo
	 * bar
	 */

I ended by merging this series,[...]

Thanks alot!

Quoted 5 lines

but please send a fixup patch
when you have some time.

Btw, specially for new drivers, it could worth running checkpatch in scritct mode:

Well. Honestly, I wasn't fully aware of the "strict" option (at least until Jasmin was told about it, but then the patches were there for some time already). Since I have two (maybe three) minors for the stv0910 driver in my GIT which I'd like to also submit, I will check and fix up things in addition.

Quoted 6 lines

Several of those warnings can be automatically fixed with:

./scripts/checkpatch.pl -f $(git diff 435945e08551|diffstat -p1 -l|grep -v MAINT) --strict --fix-inplace

But you need to review if the results are ok.

Thanks for the hints!

Best regards,
Daniel Scheller

Signature · 1 line
https://github.com/herrnst
#4 lore raw

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

In reply to Daniel Scheller

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 9dfcaf5e067f..85439d3b725e 100644
@@ -671,6 +671,7 @@ static int get_bit_error_rate_s(struct stv *state, u32 *bernumerator,
 static u32 dvbs2_nbch(enum dvbs2_mod_cod mod_cod, 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, */
@@ -703,7 +704,7 @@ static u32 dvbs2_nbch(enum dvbs2_mod_cod mod_cod, enum dvbs2_fectype fectype)
 
 	if (mod_cod >= DVBS2_QPSK_1_4 &&
 	    mod_cod <= DVBS2_32APSK_9_10 && fectype <= DVBS2_16K)
-		return nbch[fectype][mod_cod];
+		return nbch[mod_cod][fectype];
 	return 64800;
 }
 
Signature · 1 line
2.13.0
#5 lore raw

PATCH v3 3/10 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 | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/stv0910.c +28 -1
index 85439d3b725e..dc848ebe1a44 100644
@@ -119,6 +119,8 @@ struct stv {
 	int   is_standard_broadcast;
 	int   is_vcm;
 
+	u32   cur_scrambling_code;
+
 	u32   last_bernumerator;
 	u32   last_berdenominator;
 	u8    berscale;
@@ -965,6 +967,7 @@ static int start(struct stv *state, struct dtv_frontend_properties *p)
 	s32 freq;
 	u8  reg_dmdcfgmd;
 	u16 symb;
+	u32 scrambling_code = 1;
 
 	if (p->symbol_rate < 100000 || p->symbol_rate > 70000000)
 		return -EINVAL;
@@ -978,6 +981,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)
+			scrambling_code = 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 (scrambling_code != state->cur_scrambling_code) {
+		write_reg(state, RSTV0910_P2_PLROOT0 + state->regoff,
+			  scrambling_code & 0xff);
+		write_reg(state, RSTV0910_P2_PLROOT1 + state->regoff,
+			  (scrambling_code >> 8) & 0xff);
+		write_reg(state, RSTV0910_P2_PLROOT2 + state->regoff,
+			  (scrambling_code >> 16) & 0x07);
+		state->cur_scrambling_code = scrambling_code;
+	}
+
 	if (p->symbol_rate <= 1000000) {  /* SR <=1Msps */
 		state->demod_timeout = 3000;
 		state->fec_timeout = 2000;
@@ -1597,7 +1622,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,
@@ -1655,6 +1681,7 @@ struct dvb_frontend *stv0910_attach(struct i2c_adapter *i2c,
 	state->search_range = 16000000;
 	state->demod_bits = 0x10;     /* Inversion : Auto with reset to 0 */
 	state->receive_mode   = RCVMODE_NONE;
+	state->cur_scrambling_code = (~0U);
 	state->single = cfg->single ? 1 : 0;
 
 	base = match_base(i2c, cfg->adr);
Signature · 1 line
2.13.0
#6 lore raw

PATCH v3 4/10 dvb-frontends/stv0910: Add demod-only 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. Implement signal strength readout to work without asking the attached tuner, and use a lookup table instead of log calc. Values reported appear plausible, gathered from feedback from several testers.

---
 drivers/media/dvb-frontends/stv0910.c | 48 ++++++++++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 4 deletions(-)
drivers/media/dvb-frontends/stv0910.c +44 -4
index dc848ebe1a44..dc4d829bb47a 100644
@@ -135,7 +135,7 @@ struct sinit_table {
 
 struct slookup {
 	s16  value;
-	u16  reg_value;
+	u32  reg_value;
 };
 
 static inline int i2c_write(struct i2c_adapter *adap, u8 adr,
@@ -327,6 +327,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
  *********************************************************************/
@@ -567,7 +586,7 @@ static int tracking_optimization(struct stv *state)
 }
 
 static s32 table_lookup(struct slookup *table,
-		       int table_size, u16 reg_value)
+		       int table_size, u32 reg_value)
 {
 	s32 value;
 	int imin = 0;
@@ -1300,11 +1319,32 @@ static int read_ber(struct dvb_frontend *fe)
 
 static void read_signal_strength(struct dvb_frontend *fe)
 {
-	/* FIXME: add signal strength algo */
 	struct stv *state = fe->demodulator_priv;
 	struct dtv_frontend_properties *p = &state->fe.dtv_property_cache;
+	s64 strength;
+	u8 reg[2];
+	u16 agc;
+	s32 padc, power = 0;
+	int i;
 
-	p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
+	read_regs(state, RSTV0910_P2_AGCIQIN1 + state->regoff, reg, 2);
+
+	agc = (((u32) reg[0]) << 8) | reg[1];
+
+	for (i = 0; i < 5; i += 1) {
+		read_regs(state, RSTV0910_P2_POWERI + state->regoff, reg, 2);
+		power += (u32) reg[0] * (u32) reg[0]
+			+ (u32) reg[1] * (u32) reg[1];
+		usleep_range(3000, 4000);
+	}
+	power /= 5;
+
+	padc = table_lookup(padc_lookup, ARRAY_SIZE(padc_lookup), power) + 352;
+
+	strength = (padc - agc);
+
+	p->strength.stat[0].scale = FE_SCALE_DECIBEL;
+	p->strength.stat[0].uvalue = strength;
 }
 
 static int read_status(struct dvb_frontend *fe, enum fe_status *status)
Signature · 1 line
2.13.0
#7 lore raw

PATCH v3 5/10 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 dc4d829bb47a..7e8a460449c5 100644
@@ -1668,6 +1668,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
#8 lore raw

PATCH v3 6/10 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. Any camel case has been converted to kernel_case, fixup patch has been proposed upstream.

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 | 674 ++++++++++++++++++++++++++++++++++
 drivers/media/dvb-frontends/stv6111.h |  20 +
 4 files changed, 704 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 +674 -0

674 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
#9 lore raw

PATCH v3 7/10 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 cd1723e79a07..3fbac7bee2d4 100644
@@ -1480,10 +1480,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;
 }
@@ -1530,7 +1529,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;
 
@@ -1622,7 +1621,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
#10 lore raw

PATCH v3 8/10 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 | 135 ++++++++++++++++++++++++++++-
 drivers/media/pci/ddbridge/ddbridge.h      |   2 +
 3 files changed, 138 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 +132 -3

177 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
#11 lore raw

PATCH v3 9/10 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 b3fc6a875279..e762396730db 100644
@@ -53,6 +53,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 */
@@ -942,6 +946,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
#12 lore raw

PATCH v3 10/10 MAINTAINERS: add entries for stv0910 and stv6111

In reply to Daniel Scheller

From: Daniel Scheller <[email protected]>

---
 MAINTAINERS | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
MAINTAINERS +16 -0
index c4be6d4af7d2..7b85e578d238 100644
@@ -8246,6 +8246,22 @@ T:	git git://linuxtv.org/media_tree.git
 S:	Supported
 F:	drivers/media/pci/netup_unidvb/*
 
+MEDIA DRIVERS FOR ST STV0910 DEMODULATOR ICs
+M:	Daniel Scheller <[email protected]>
+L:	[email protected]
+W:	https://linuxtv.org
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/dvb-frontends/stv0910*
+
+MEDIA DRIVERS FOR ST STV6111 TUNER ICs
+M:	Daniel Scheller <[email protected]>
+L:	[email protected]
+W:	https://linuxtv.org
+T:	git git://linuxtv.org/media_tree.git
+S:	Maintained
+F:	drivers/media/dvb-frontends/stv6111*
+
 MEDIA INPUT INFRASTRUCTURE (V4L/DVB)
 M:	Mauro Carvalho Chehab <[email protected]>
 M:	Mauro Carvalho Chehab <[email protected]>
Signature · 1 line
2.13.0