Re: [PATCH v3 0/3] IOCTLs in ddbridge.

2018-07-04 Thread Daniel Scheller
Am Wed, 4 Jul 2018 13:08:31 -0300
schrieb Mauro Carvalho Chehab :

> Em Sat, 12 May 2018 13:24:29 +0200
> Daniel Scheller  escreveu:
> 
> > From: Daniel Scheller 
> > 
> > Third iteration of the IOCTL patches for ddbridge, split into multiple
> > patches:
> > 
> > Patch 1 just adds the reservation/information of the used IOCTLs into
> > ioctl-numbers.txt in the Docs dir. Doc, s390 and LKML are Cc'ed on
> > this patch.  
> 
> Patch looks ok, although it would be great to get some acks there.
> I don't know who currently maintains Documentation/ioctl/ioctl-number.txt.
> 
> Just in case, I would explicitly c/c LKML, Andrew Morton and Jonathan Corbet.
> Please c/c them [...]

I did in patch 1 explicitly asking esp. the s390 guys since they're on
0xDD too but at a lower range, no response in two months, from anyone.

> on a next respin. [...] What I miss here is a forth patch to 
> Documentation/media/dvb-drivers/,
> adding a documentation for ddbridge, in special explaining those new
> ioctls.

If you're fine with anything else in this series, please be so kind and
pick this stuff up and I'll shove such doc up afterwards as a separate
patch. This whole thing is being posted for over a year now, I waited
another two months, and I'm not interested in waiting for another such
long time (or even more) regarding this (remember I even asked for
review for the 4.18 merge window).

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH] [media] dvb-frontends/tda18271c2dd: silence sparse fall through warning

2018-06-24 Thread Daniel Scheller
From: Daniel Scheller 

Add a break statement in set_params() for the SYS_DVBT(2) case to silence
this sparse warning:

drivers/media/dvb-frontends/tda18271c2dd.c:1144:3: warning: this statement 
may fall through [-Wimplicit-fallthrough=]

as reported in Hans' daily media_tree builds.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/tda18271c2dd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c 
b/drivers/media/dvb-frontends/tda18271c2dd.c
index 2e1d36ae943b..fcffc7b4acf7 100644
--- a/drivers/media/dvb-frontends/tda18271c2dd.c
+++ b/drivers/media/dvb-frontends/tda18271c2dd.c
@@ -1154,6 +1154,7 @@ static int set_params(struct dvb_frontend *fe)
default:
return -EINVAL;
}
+   break;
case SYS_DVBC_ANNEX_A:
case SYS_DVBC_ANNEX_C:
if (bw <= 600)
-- 
2.16.4



[PATCH 06/19] [media] ddbridge: remove unused MDIO defines and hwinfo member

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

ddbridge has a few MDIO related remainders (defines, hwinfo struct) which
aren't of any use for the in-kernel driver at all (they're only used in
conjunction with the OctoNet SAT>IP boxes which the kernel driver doesn't
have any support for), so clean this up.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-regs.h | 8 
 drivers/media/pci/ddbridge/ddbridge.h  | 1 -
 2 files changed, 9 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-regs.h 
b/drivers/media/pci/ddbridge/ddbridge-regs.h
index b978b5991940..f9e1cbb99b53 100644
--- a/drivers/media/pci/ddbridge/ddbridge-regs.h
+++ b/drivers/media/pci/ddbridge/ddbridge-regs.h
@@ -33,14 +33,6 @@
 #define GPIO_INPUT   0x24
 #define GPIO_DIRECTION   0x28
 
-/* - */
-/* MDIO */
-
-#define MDIO_CTRL0x20
-#define MDIO_ADR 0x24
-#define MDIO_REG 0x28
-#define MDIO_VAL 0x2C
-
 /* - */
 
 #define BOARD_CONTROL0x30
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index a66b1125cc74..9c645bee428a 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -127,7 +127,6 @@ struct ddb_info {
u8temp_bus;
u32   board_control;
u32   board_control_2;
-   u8mdio_num;
u8con_clock; /* use a continuous clock */
u8ts_quirks;
 #define TS_QUIRK_SERIAL   1
-- 
2.16.4



[PATCH 11/19] [media] ddbridge/mci: rename defines and fix i/q var types

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Adjustments to match the FPGA firmware, and the signal I/Q values are
reported as s16 types from the card firmware.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.c |  2 +-
 drivers/media/pci/ddbridge/ddbridge-mci.h | 56 +++
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index 7d402861fa9e..fa0d7d0cc6f6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -342,7 +342,7 @@ static int start(struct dvb_frontend *fe, u32 flags, u32 
modmask, u32 ts_config)
memset(, 0, sizeof(cmd));
 
if (state->base->iq_mode) {
-   cmd.command = SX8_CMD_SELECT_IQOUT;
+   cmd.command = SX8_CMD_ENABLE_IQOUTPUT;
cmd.demod = state->demod;
cmd.output = 0;
mci_cmd(state, , NULL);
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index 389f6376603b..2e74f0544717 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -51,40 +51,40 @@
 #define SX8_TSCONFIG_BURSTSIZE_8K   (0x0020)
 #define SX8_TSCONFIG_BURSTSIZE_16K  (0x0030)
 
-#define SX8_DEMOD_STOPPED   (0)
-#define SX8_DEMOD_IQ_MODE   (1)
-#define SX8_DEMOD_WAIT_SIGNAL   (2)
-#define SX8_DEMOD_WAIT_MATYPE   (3)
-#define SX8_DEMOD_TIMEOUT   (14)
-#define SX8_DEMOD_LOCKED(15)
+#define SX8_DEMOD_STOPPED(0)
+#define SX8_DEMOD_IQ_MODE(1)
+#define SX8_DEMOD_WAIT_SIGNAL(2)
+#define SX8_DEMOD_WAIT_MATYPE(3)
+#define SX8_DEMOD_TIMEOUT(14)
+#define SX8_DEMOD_LOCKED (15)
 
-#define MCI_CMD_STOP(0x01)
-#define MCI_CMD_GETSTATUS   (0x02)
-#define MCI_CMD_GETSIGNALINFO   (0x03)
-#define MCI_CMD_RFPOWER (0x04)
+#define MCI_CMD_STOP (0x01)
+#define MCI_CMD_GETSTATUS(0x02)
+#define MCI_CMD_GETSIGNALINFO(0x03)
+#define MCI_CMD_RFPOWER  (0x04)
 
-#define MCI_CMD_SEARCH_DVBS (0x10)
+#define MCI_CMD_SEARCH_DVBS  (0x10)
 
-#define MCI_CMD_GET_IQSYMBOL(0x30)
+#define MCI_CMD_GET_IQSYMBOL (0x30)
 
-#define SX8_CMD_INPUT_ENABLE(0x40)
-#define SX8_CMD_INPUT_DISABLE   (0x41)
-#define SX8_CMD_START_IQ(0x42)
-#define SX8_CMD_STOP_IQ (0x43)
-#define SX8_CMD_SELECT_IQOUT(0x44)
-#define SX8_CMD_SELECT_TSOUT(0x45)
+#define SX8_CMD_INPUT_ENABLE (0x40)
+#define SX8_CMD_INPUT_DISABLE(0x41)
+#define SX8_CMD_START_IQ (0x42)
+#define SX8_CMD_STOP_IQ  (0x43)
+#define SX8_CMD_ENABLE_IQOUTPUT  (0x44)
+#define SX8_CMD_DISABLE_IQOUTPUT (0x45)
 
-#define SX8_ERROR_UNSUPPORTED   (0x80)
+#define MCI_ERROR_UNSUPPORTED(0x80)
 
-#define SX8_SUCCESS(status) (status < SX8_ERROR_UNSUPPORTED)
+#define MCI_SUCCESS(status)  (status < MCI_ERROR_UNSUPPORTED)
 
-#define SX8_CMD_DIAG_READ8  (0xE0)
-#define SX8_CMD_DIAG_READ32 (0xE1)
-#define SX8_CMD_DIAG_WRITE8 (0xE2)
-#define SX8_CMD_DIAG_WRITE32(0xE3)
+#define SX8_CMD_DIAG_READ8   (0xE0)
+#define SX8_CMD_DIAG_READ32  (0xE1)
+#define SX8_CMD_DIAG_WRITE8  (0xE2)
+#define SX8_CMD_DIAG_WRITE32 (0xE3)
 
-#define SX8_CMD_DIAG_READRF (0xE8)
-#define SX8_CMD_DIAG_WRITERF(0xE9)
+#define SX8_CMD_DIAG_READRF  (0xE8)
+#define SX8_CMD_DIAG_WRITERF (0xE9)
 
 struct mci_command {
union {
@@ -141,8 +141,8 @@ struct mci_result {
u32 ber_denominator;
} dvbs2_signal_info;
struct {
-   u8 i_symbol;
-   u8 q_symbol;
+   s16 i;
+   s16 q;
} dvbs2_signal_iq;
};
u32 version[4];
-- 
2.16.4



[PATCH 02/19] [media] dvb-frontends/stv0910: cast the BER denominator shift exp to ULL

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

To avoid miscalculations related to the BER denominator, the shift
expression needs to be casted as ULL.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0910.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 41444fa1c0bb..91b21eb59531 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -682,8 +682,8 @@ static int get_bit_error_rate_s(struct stv *state, u32 
*bernumerator,
return -EINVAL;
 
if ((regs[0] & 0x80) == 0) {
-   state->last_berdenominator = 1 << ((state->berscale * 2) +
- 10 + 3);
+   state->last_berdenominator = 1ULL << ((state->berscale * 2) +
+10 + 3);
state->last_bernumerator = ((u32)(regs[0] & 0x7F) << 16) |
((u32)regs[1] << 8) | regs[2];
if (state->last_bernumerator < 256 && state->berscale < 6) {
-- 
2.16.4



[PATCH 07/19] [media] ddbridge: link structure access cosmetics in ddb_port_probe()

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Throughout the function, dev->link[l] is used several times. Unclutter
this a bit by declaring a ddb_link var at the top of the function, assign
the address of dev->link[l] to it and use that var to access the link[]
struct member.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 55eb151f329e..408460be00b7 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1850,6 +1850,7 @@ static void ddb_port_probe(struct ddb_port *port)
 {
struct ddb *dev = port->dev;
u32 l = port->lnr;
+   struct ddb_link *link = >link[l];
u8 id, type;
 
port->name = "NO MODULE";
@@ -1859,7 +1860,7 @@ static void ddb_port_probe(struct ddb_port *port)
/* Handle missing ports and ports without I2C */
 
if (dummy_tuner && !port->nr &&
-   dev->link[l].ids.device == 0x0005) {
+   link->ids.device == 0x0005) {
port->name = "DUMMY";
port->class = DDB_PORT_TUNER;
port->type = DDB_TUNER_DUMMY;
@@ -1873,14 +1874,14 @@ static void ddb_port_probe(struct ddb_port *port)
return;
}
 
-   if (port->nr == 1 && dev->link[l].info->type == DDB_OCTOPUS_CI &&
-   dev->link[l].info->i2c_mask == 1) {
+   if (port->nr == 1 && link->info->type == DDB_OCTOPUS_CI &&
+   link->info->i2c_mask == 1) {
port->name = "NO TAB";
port->class = DDB_PORT_NONE;
return;
}
 
-   if (dev->link[l].info->type == DDB_OCTOPUS_MAX) {
+   if (link->info->type == DDB_OCTOPUS_MAX) {
port->name = "DUAL DVB-S2 MAX";
port->type_name = "MXL5XX";
port->class = DDB_PORT_TUNER;
@@ -1891,8 +1892,8 @@ static void ddb_port_probe(struct ddb_port *port)
return;
}
 
-   if (dev->link[l].info->type == DDB_OCTOPUS_MCI) {
-   if (port->nr >= dev->link[l].info->mci)
+   if (link->info->type == DDB_OCTOPUS_MCI) {
+   if (port->nr >= link->info->mci)
return;
port->name = "DUAL MCI";
port->type_name = "MCI";
@@ -1901,7 +1902,7 @@ static void ddb_port_probe(struct ddb_port *port)
return;
}
 
-   if (port->nr > 1 && dev->link[l].info->type == DDB_OCTOPUS_CI) {
+   if (port->nr > 1 && link->info->type == DDB_OCTOPUS_CI) {
port->name = "CI internal";
port->type_name = "INTERNAL";
port->class = DDB_PORT_CI;
@@ -1986,7 +1987,7 @@ static void ddb_port_probe(struct ddb_port *port)
port->class = DDB_PORT_TUNER;
if (id == 0x51) {
if (port->nr == 0 &&
-   dev->link[l].info->ts_quirks & TS_QUIRK_REVERSED)
+   link->info->ts_quirks & TS_QUIRK_REVERSED)
port->type = DDB_TUNER_DVBS_STV0910_PR;
else
port->type = DDB_TUNER_DVBS_STV0910_P;
-- 
2.16.4



[PATCH 17/19] [media] ddbridge/sx8: disable automatic PLS code search

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

The SX8 cards by default do an automatic search for the PLS code. This
is not necessarily wanted as this can eventually be detected wrong, so
disable this.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-sx8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-sx8.c 
b/drivers/media/pci/ddbridge/ddbridge-sx8.c
index 1a12f2105490..c87cefa10762 100644
--- a/drivers/media/pci/ddbridge/ddbridge-sx8.c
+++ b/drivers/media/pci/ddbridge/ddbridge-sx8.c
@@ -292,7 +292,7 @@ static int start(struct dvb_frontend *fe, u32 flags, u32 
modmask, u32 ts_config)
cmd.dvbs2_search.frequency = p->frequency * 1000;
cmd.dvbs2_search.symbol_rate = p->symbol_rate;
cmd.dvbs2_search.scrambling_sequence_index =
-   p->scrambling_sequence_index;
+   p->scrambling_sequence_index | 0x8000;
cmd.dvbs2_search.input_stream_id =
(p->stream_id != NO_STREAM_ID_FILTER) ? p->stream_id : 0;
cmd.tuner = state->mci.tuner;
-- 
2.16.4



[PATCH 03/19] [media] ddbridge: probe for LNBH25 chips before attaching

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

In demod_attach_stv0910(), the LNBH25 IC is being blindly attached and,
if the result is bad, blindly attached on another possible I2C address.
The LNBH25 uses it's set_voltage function to test for the IC and will
print an error to the kernel log on failure. Prevent this by probing
the possible I2C address and use this (and only this) to attach the
LNBH25 I2C driver. This also allows the stv0910 attach function to be
a bit cleaner.

Picked up from the upstream dddvb GIT and adapted for the LNBH25 driver
variant from the kernel tree.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index d5b0d1eaf3ad..3f83415b06c7 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1191,6 +1191,13 @@ static const struct lnbh25_config lnbh25_cfg = {
.data2_config = LNBH25_TEN
 };
 
+static int has_lnbh25(struct i2c_adapter *i2c, u8 adr)
+{
+   u8 val;
+
+   return i2c_read_reg(i2c, adr, 0, ) ? 0 : 1;
+}
+
 static int demod_attach_stv0910(struct ddb_input *input, int type, int tsfast)
 {
struct i2c_adapter *i2c = >port->i2c->adap;
@@ -1224,14 +1231,15 @@ static int demod_attach_stv0910(struct ddb_input 
*input, int type, int tsfast)
/* attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit
 * i2c addresses
 */
-   lnbcfg.i2c_address = (((input->nr & 1) ? 0x0d : 0x0c) << 1);
-   if (!dvb_attach(lnbh25_attach, dvb->fe, , i2c)) {
+   if (has_lnbh25(i2c, 0x0d))
+   lnbcfg.i2c_address = (((input->nr & 1) ? 0x0d : 0x0c) << 1);
+   else
lnbcfg.i2c_address = (((input->nr & 1) ? 0x09 : 0x08) << 1);
-   if (!dvb_attach(lnbh25_attach, dvb->fe, , i2c)) {
-   dev_err(dev, "No LNBH25 found!\n");
-   dvb_frontend_detach(dvb->fe);
-   return -ENODEV;
-   }
+
+   if (!dvb_attach(lnbh25_attach, dvb->fe, , i2c)) {
+   dev_err(dev, "No LNBH25 found!\n");
+   dvb_frontend_detach(dvb->fe);
+   return -ENODEV;
}
 
return 0;
-- 
2.16.4



[PATCH 16/19] [media] ddbridge/mci: add more MCI status codes, improve MCI_SUCCESS macro

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

The MCI can report the command status more finegrained, so, add more
status code defines and update the MCI_SUCCESS macro.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.h | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index f02bc76e3c98..600a8bc642c4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -74,9 +74,13 @@
 #define SX8_CMD_ENABLE_IQOUTPUT  (0x44)
 #define SX8_CMD_DISABLE_IQOUTPUT (0x45)
 
-#define MCI_ERROR_UNSUPPORTED(0x80)
+#define MCI_STATUS_OK(0x00)
+#define MCI_STATUS_UNSUPPORTED   (0x80)
+#define MCI_STATUS_RETRY (0xFD)
+#define MCI_STATUS_NOT_READY (0xFE)
+#define MCI_STATUS_ERROR (0xFF)
 
-#define MCI_SUCCESS(status)  (status < MCI_ERROR_UNSUPPORTED)
+#define MCI_SUCCESS(status)  ((status & MCI_STATUS_UNSUPPORTED) == 0)
 
 #define SX8_CMD_DIAG_READ8   (0xE0)
 #define SX8_CMD_DIAG_READ32  (0xE1)
-- 
2.16.4



[PATCH 12/19] [media] ddbridge/mci: extend mci_command and mci_result structs

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Recent FPGA firmware reports more data and values in sent command
responses. Adjust the mci_command and mci_result structs including it's
unions to match these changes and add a few comments explaining things.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.h | 74 +++
 1 file changed, 66 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index 2e74f0544717..5e0c9e88b6fc 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -90,16 +90,30 @@ struct mci_command {
union {
u32 command_word;
struct {
-   u8 command;
-   u8 tuner;
-   u8 demod;
-   u8 output;
+   u8  command;
+   u8  tuner;
+   u8  demod;
+   u8  output;
};
};
union {
u32 params[31];
struct {
+   /*
+* Bit 0: DVB-S Enabled
+* Bit 1: DVB-S2 Enabled
+* Bit 7: InputStreamID
+*/
u8  flags;
+   /*
+* Bit 0: QPSK,
+* Bit 1: 8PSK/8APSK
+* Bit 2: 16APSK
+* Bit 3: 32APSK
+* Bit 4: 64APSK
+* Bit 5: 128APSK
+* Bit 6: 256APSK
+*/
u8  s2_modulation_mask;
u8  rsvd1;
u8  retry;
@@ -108,7 +122,36 @@ struct mci_command {
u8  input_stream_id;
u8  rsvd2[3];
u32 scrambling_sequence_index;
+   u32 frequency_range;
} dvbs2_search;
+
+   struct {
+   u8  tap;
+   u8  rsvd;
+   u16 point;
+   } get_iq_symbol;
+
+   struct {
+   /*
+* Bit 0: 0=VTM/1=SCAN
+* Bit 1: Set Gain
+*/
+   u8  flags;
+   u8  roll_off;
+   u8  rsvd1;
+   u8  rsvd2;
+   u32 frequency;
+   u32 symbol_rate; /* Only in VTM mode */
+   u16 gain;
+   } sx8_start_iq;
+
+   struct {
+   /*
+* Bit 1:0 = STVVGLNA Gain.
+*   0 = AGC, 1 = 0dB, 2 = Minimum, 3 = Maximum
+*/
+   u8  flags;
+   } sx8_input_enable;
};
 };
 
@@ -116,34 +159,49 @@ struct mci_result {
union {
u32 status_word;
struct {
-   u8 status;
-   u8 rsvd;
+   u8  status;
+   u8  mode;
u16 time;
};
};
union {
u32 result[27];
struct {
+   /* 1 = DVB-S, 2 = DVB-S2X */
u8  standard;
/* puncture rate for DVB-S */
u8  pls_code;
-   /* 7-6: rolloff, 5-2: rsrvd, 1:short, 0:pilots */
+   /* 2-0: rolloff */
u8  roll_off;
u8  rsvd;
+   /* actual frequency in Hz */
u32 frequency;
+   /* actual symbolrate in Hz */
u32 symbol_rate;
+   /* channel power in dBm x 100 */
s16 channel_power;
+   /* band power in dBm x 100 */
s16 band_power;
+   /*
+* SNR in dB x 100
+* Note: negative values are valid in DVB-S2
+*/
s16 signal_to_noise;
s16 rsvd2;
+   /*
+* Counter for packet errors
+* (set to 0 on start command)
+*/
u32 packet_errors;
+   /* Bit error rate: PreRS in DVB-S, PreBCH in DVB-S2X */
u32 ber_numerator;
u32 ber_denominator;
} dvbs2_signal_info;
+
struct {
s16 i;
s16 q

[PATCH 09/19] [media] ddbridge/mci: update copyright year in headers

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Update the copyright year information in the MCI headers to 2017-2018.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.c | 6 +++---
 drivers/media/pci/ddbridge/ddbridge-mci.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index 4ac634fc96e4..46b20b06e2a6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -2,9 +2,9 @@
 /*
  * ddbridge-mci.c: Digital Devices microcode interface
  *
- * Copyright (C) 2017 Digital Devices GmbH
- *Ralph Metzler 
- *Marcus Metzler 
+ * Copyright (C) 2017-2018 Digital Devices GmbH
+ * Ralph Metzler 
+ * Marcus Metzler 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index 209cc2b92dff..389f6376603b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -2,9 +2,9 @@
 /*
  * ddbridge-mci.h: Digital Devices micro code interface
  *
- * Copyright (C) 2017 Digital Devices GmbH
- *Marcus Metzler 
- *Ralph Metzler 
+ * Copyright (C) 2017-2018 Digital Devices GmbH
+ * Marcus Metzler 
+ * Ralph Metzler 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
-- 
2.16.4



[PATCH 10/19] [media] ddbridge/mci: read and report signal strength and SNR

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Implement querying signal statistics from the MCI and report this data
in read_status() as DVBv5 statistics.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.c | 47 ++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index 46b20b06e2a6..7d402861fa9e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -155,6 +155,47 @@ static void release(struct dvb_frontend *fe)
kfree(state);
 }
 
+static int get_info(struct dvb_frontend *fe)
+{
+   int stat;
+   struct mci *state = fe->demodulator_priv;
+   struct mci_command cmd;
+
+   memset(, 0, sizeof(cmd));
+   cmd.command = MCI_CMD_GETSIGNALINFO;
+   cmd.demod = state->demod;
+   stat = mci_cmd(state, , >signal_info);
+   return stat;
+}
+
+static int get_snr(struct dvb_frontend *fe)
+{
+   struct mci *state = fe->demodulator_priv;
+   struct dtv_frontend_properties *p = >dtv_property_cache;
+
+   p->cnr.len = 1;
+   p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+   p->cnr.stat[0].svalue =
+   (s64)state->signal_info.dvbs2_signal_info.signal_to_noise
+* 10;
+   return 0;
+}
+
+static int get_strength(struct dvb_frontend *fe)
+{
+   struct mci *state = fe->demodulator_priv;
+   struct dtv_frontend_properties *p = >dtv_property_cache;
+   s32 str;
+
+   str = 10 -
+ (state->signal_info.dvbs2_signal_info.channel_power
+  * 10 + 108750);
+   p->strength.len = 1;
+   p->strength.stat[0].scale = FE_SCALE_DECIBEL;
+   p->strength.stat[0].svalue = str;
+   return 0;
+}
+
 static int read_status(struct dvb_frontend *fe, enum fe_status *status)
 {
int stat;
@@ -168,10 +209,14 @@ static int read_status(struct dvb_frontend *fe, enum 
fe_status *status)
if (stat)
return stat;
*status = 0x00;
+   get_info(fe);
+   get_strength(fe);
if (res.status == SX8_DEMOD_WAIT_MATYPE)
*status = 0x0f;
-   if (res.status == SX8_DEMOD_LOCKED)
+   if (res.status == SX8_DEMOD_LOCKED) {
*status = 0x1f;
+   get_snr(fe);
+   }
return stat;
 }
 
-- 
2.16.4



[PATCH 13/19] [media] ddbridge/mci: store mci type and number of ports in the hwinfo

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

For better support for future MCI based cards, rename the mci struct
member to mci_ports to carry the number of ports on the cards, and add a
mci_type member to identify the card type to handle differing hardware.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++--
 drivers/media/pci/ddbridge/ddbridge-hw.c   | 3 ++-
 drivers/media/pci/ddbridge/ddbridge.h  | 9 ++---
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 68ea0ffdad2d..67b60da12cf4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1893,12 +1893,12 @@ static void ddb_port_probe(struct ddb_port *port)
}
 
if (link->info->type == DDB_OCTOPUS_MCI) {
-   if (port->nr >= link->info->mci)
+   if (port->nr >= link->info->mci_ports)
return;
port->name = "DUAL MCI";
port->type_name = "MCI";
port->class = DDB_PORT_TUNER;
-   port->type = DDB_TUNER_MCI_SX8;
+   port->type = DDB_TUNER_MCI + link->info->mci_type;
return;
}
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c 
b/drivers/media/pci/ddbridge/ddbridge-hw.c
index 1d3ee6accdd5..f3cbac07b41f 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.c
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -318,7 +318,8 @@ static const struct ddb_info ddb_s2x_48 = {
.port_num = 4,
.i2c_mask = 0x00,
.tempmon_irq = 24,
-   .mci  = 4
+   .mci_ports = 4,
+   .mci_type = 0,
 };
 
 //
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 65bd74d86ed5..8a354dfb6c22 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -120,20 +120,23 @@ struct ddb_info {
 #define DDB_OCTOPUS_MCI 9
char *name;
u32   i2c_mask;
+   u32   board_control;
+   u32   board_control_2;
+
u8port_num;
u8led_num;
u8fan_num;
u8temp_num;
u8temp_bus;
-   u32   board_control;
-   u32   board_control_2;
u8con_clock; /* use a continuous clock */
u8ts_quirks;
 #define TS_QUIRK_SERIAL   1
 #define TS_QUIRK_REVERSED 2
 #define TS_QUIRK_ALT_OSC  8
+   u8mci_ports;
+   u8mci_type;
+
u32   tempmon_irq;
-   u8mci;
const struct ddb_regmap *regmap;
 };
 
-- 
2.16.4



[PATCH 19/19] [media] ddbridge/mci: add SX8 I/Q mode remark and remove DIAG CMD defines

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Take note that the SX8 IQ mode is only available on a single tuner, and
remove the MCI/SX8 DIAG CMD defines.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.h | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index 600a8bc642c4..2424c634 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -42,6 +42,22 @@
 #define SX8_TSCONFIG_MODE_NORMAL(0x0001)
 #define SX8_TSCONFIG_MODE_IQ(0x0003)
 
+/*
+ * IQMode is only available on MaxSX8 on a single tuner
+ *
+ * IQ_MODE_SAMPLES
+ *   sampling rate is 1550/24 MHz (64.583 MHz)
+ *   channel agc is frozen, to allow stitching the FFT results together
+ *
+ * IQ_MODE_VTM
+ *   sampling rate is the supplied symbolrate
+ *   channel agc is active
+ *
+ * in both cases down sampling is done with a RRC Filter (currently fixed to
+ * alpha = 0.05) which causes some (ca 5%) aliasing at the edges from
+ * outside the spectrum
+ */
+
 #define SX8_TSCONFIG_TSHEADER   (0x0004)
 #define SX8_TSCONFIG_BURST  (0x0008)
 
@@ -82,14 +98,6 @@
 
 #define MCI_SUCCESS(status)  ((status & MCI_STATUS_UNSUPPORTED) == 0)
 
-#define SX8_CMD_DIAG_READ8   (0xE0)
-#define SX8_CMD_DIAG_READ32  (0xE1)
-#define SX8_CMD_DIAG_WRITE8  (0xE2)
-#define SX8_CMD_DIAG_WRITE32 (0xE3)
-
-#define SX8_CMD_DIAG_READRF  (0xE8)
-#define SX8_CMD_DIAG_WRITERF (0xE9)
-
 struct mci_command {
union {
u32 command_word;
-- 
2.16.4



[PATCH 15/19] [media] ddbridge/mci: split MaxSX8 specific code off to ddbridge-sx8.c

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Split off all code specific to the MaxSX8 cards to a separate ddbridge-sx8
module and hook it up in the Makefile. This also adds evaluation of the
mci_type to allow for using different attach handling for different cards.
As different cards can implement things differently (ie. support differing
frontend_ops, and have different base structs being put ontop of the
common mci_base struct), this introduces the mci_cfg struct which is
initially used to hold a few specifics to the -sx8 submodule. While at it,
the handling of the i/q mode is adjusted slightly. Besides this and
handling mci_base and sx8_base struct pointers where needed, all code
is copied unmodified from ddbridge-mci.c.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/Makefile|   3 +-
 drivers/media/pci/ddbridge/ddbridge-core.c |   2 +-
 drivers/media/pci/ddbridge/ddbridge-max.c  |  18 +-
 drivers/media/pci/ddbridge/ddbridge-max.h  |   2 +-
 drivers/media/pci/ddbridge/ddbridge-mci.c  | 408 +
 drivers/media/pci/ddbridge/ddbridge-mci.h  |  28 +-
 drivers/media/pci/ddbridge/ddbridge-sx8.c  | 474 +
 7 files changed, 516 insertions(+), 419 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-sx8.c

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index 9b9e35f171b7..5b6d5bbc38af 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -4,7 +4,8 @@
 #
 
 ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \
-   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o ddbridge-mci.o
+   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o ddbridge-mci.o \
+   ddbridge-sx8.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 67b60da12cf4..c1b982e8e6c9 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1593,7 +1593,7 @@ static int dvb_input_attach(struct ddb_input *input)
goto err_detach;
break;
case DDB_TUNER_MCI_SX8:
-   if (ddb_fe_attach_mci(input) < 0)
+   if (ddb_fe_attach_mci(input, port->type) < 0)
goto err_detach;
break;
default:
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c 
b/drivers/media/pci/ddbridge/ddbridge-max.c
index 739e4b444cf4..8da1c7b91577 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.c
+++ b/drivers/media/pci/ddbridge/ddbridge-max.c
@@ -457,21 +457,29 @@ int ddb_fe_attach_mxl5xx(struct ddb_input *input)
 
/**/
 /* MAX MCI related functions */
 
-int ddb_fe_attach_mci(struct ddb_input *input)
+int ddb_fe_attach_mci(struct ddb_input *input, u32 type)
 {
struct ddb *dev = input->port->dev;
struct ddb_dvb *dvb = >port->dvb[input->nr & 1];
struct ddb_port *port = input->port;
struct ddb_link *link = >link[port->lnr];
int demod, tuner;
+   struct mci_cfg cfg;
 
demod = input->nr;
tuner = demod & 3;
-   if (fmode == 3)
-   tuner = 0;
-   dvb->fe = ddb_mci_attach(input, 0, demod, >set_input);
+   switch (type) {
+   case DDB_TUNER_MCI_SX8:
+   cfg = ddb_max_sx8_cfg;
+   if (fmode == 3)
+   tuner = 0;
+   break;
+   default:
+   return -EINVAL;
+   }
+   dvb->fe = ddb_mci_attach(input, , demod, >set_input);
if (!dvb->fe) {
-   dev_err(dev->dev, "No MAXSX8 found!\n");
+   dev_err(dev->dev, "No MCI card found!\n");
return -ENODEV;
}
if (!dvb->set_input) {
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h 
b/drivers/media/pci/ddbridge/ddbridge-max.h
index 82efc53baa94..9838c73973b6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.h
+++ b/drivers/media/pci/ddbridge/ddbridge-max.h
@@ -25,6 +25,6 @@
 
 int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
 int ddb_fe_attach_mxl5xx(struct ddb_input *input);
-int ddb_fe_attach_mci(struct ddb_input *input);
+int ddb_fe_attach_mci(struct ddb_input *input, u32 type);
 
 #endif /* _DDBRIDGE_MAX_H */
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index a29ff25d9029..97384ae9ad27 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -22,10 +22,6 @@
 
 static LIST_HEAD(mci_list);
 
-static const u32 MCLK = (155000 / 12);
-static const u32 MAX_DEMOD_LDPC_BITRATE = (155000 / 6);
-static const u32 MAX_LDPC_BITRATE = (72000);
-
 stat

[PATCH 14/19] [media] ddbridge/mci: make ddb_mci_cmd() and ddb_mci_config() public

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

In preparation for splitting all MaxSX8 related code parts from the common
MCI code, prefix both mci_cmd() and mci_config() functions with ddb_,
remove the static marking and add matching function prototypes to
ddbridge-mci.h so these functions can be reused from other files within
the ddbridge driver. As this requires the mci-related structs to be
defined in ddbridge-mci.h, move struct mci and struct mci_base there and
clean them up.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-mci.c | 62 ---
 drivers/media/pci/ddbridge/ddbridge-mci.h | 36 ++
 2 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index fa0d7d0cc6f6..a29ff25d9029 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -26,38 +26,6 @@ static const u32 MCLK = (155000 / 12);
 static const u32 MAX_DEMOD_LDPC_BITRATE = (155000 / 6);
 static const u32 MAX_LDPC_BITRATE = (72000);
 
-struct mci_base {
-   struct list_head mci_list;
-   void*key;
-   struct ddb_link *link;
-   struct completioncompletion;
-
-   struct device   *dev;
-   struct mutex tuner_lock; /* concurrent tuner access lock */
-   u8   adr;
-   struct mutex mci_lock; /* concurrent MCI access lock */
-   int  count;
-
-   u8   tuner_use_count[MCI_TUNER_MAX];
-   u8   assigned_demod[MCI_DEMOD_MAX];
-   u32  used_ldpc_bitrate[MCI_DEMOD_MAX];
-   u8   demod_in_use[MCI_DEMOD_MAX];
-   u32  iq_mode;
-};
-
-struct mci {
-   struct mci_base *base;
-   struct dvb_frontend  fe;
-   int  nr;
-   int  demod;
-   int  tuner;
-   int  first_time_lock;
-   int  started;
-   struct mci_resultsignal_info;
-
-   u32  bb_mode;
-};
-
 static int mci_reset(struct mci *state)
 {
struct ddb_link *link = state->base->link;
@@ -84,7 +52,7 @@ static int mci_reset(struct mci *state)
return 0;
 }
 
-static int mci_config(struct mci *state, u32 config)
+int ddb_mci_config(struct mci *state, u32 config)
 {
struct ddb_link *link = state->base->link;
 
@@ -122,9 +90,9 @@ static int _mci_cmd_unlocked(struct mci *state,
return 0;
 }
 
-static int mci_cmd(struct mci *state,
-  struct mci_command *command,
-  struct mci_result *result)
+int ddb_mci_cmd(struct mci *state,
+   struct mci_command *command,
+   struct mci_result *result)
 {
int stat;
 
@@ -164,7 +132,7 @@ static int get_info(struct dvb_frontend *fe)
memset(, 0, sizeof(cmd));
cmd.command = MCI_CMD_GETSIGNALINFO;
cmd.demod = state->demod;
-   stat = mci_cmd(state, , >signal_info);
+   stat = ddb_mci_cmd(state, , >signal_info);
return stat;
 }
 
@@ -205,7 +173,7 @@ static int read_status(struct dvb_frontend *fe, enum 
fe_status *status)
 
cmd.command = MCI_CMD_GETSTATUS;
cmd.demod = state->demod;
-   stat = mci_cmd(state, , );
+   stat = ddb_mci_cmd(state, , );
if (stat)
return stat;
*status = 0x00;
@@ -228,7 +196,7 @@ static int mci_set_tuner(struct dvb_frontend *fe, u32 
tuner, u32 on)
memset(, 0, sizeof(cmd));
cmd.tuner = state->tuner;
cmd.command = on ? SX8_CMD_INPUT_ENABLE : SX8_CMD_INPUT_DISABLE;
-   return mci_cmd(state, , NULL);
+   return ddb_mci_cmd(state, , NULL);
 }
 
 static int stop(struct dvb_frontend *fe)
@@ -241,13 +209,13 @@ static int stop(struct dvb_frontend *fe)
if (state->demod != DEMOD_UNUSED) {
cmd.command = MCI_CMD_STOP;
cmd.demod = state->demod;
-   mci_cmd(state, , NULL);
+   ddb_mci_cmd(state, , NULL);
if (state->base->iq_mode) {
cmd.command = MCI_CMD_STOP;
cmd.demod = state->demod;
cmd.output = 0;
-   mci_cmd(state, , NULL);
-   mci_config(state, SX8_TSCONFIG_MODE_NORMAL);
+   ddb_mci_cmd(state, , NULL);
+   ddb_mci_config(state, SX8_TSCONFIG_MODE_NORMAL);
}
}
mutex_lock(>base->tuner_lock);
@@ -345,8 +313,8 @@ static int start(struct dvb_frontend *fe, u32 flags, u32 
modmask, u32 ts_config)
cmd.command = SX8_CMD_ENABLE_IQOUTPUT;
cmd.demod = state->demod;
cmd.output = 0;
-   mci_cmd(state, ,

[PATCH 18/19] [media] ddbridge/sx8: enable modulation selection in set_parameters()

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Allow for tuning to transponders with specific modulations in
set_parameters(). Setting a specific modulation will also enable lower
modulations.

Picked up from the upstream dddvb GIT. Upstream also has support for
APSK64/128/256 modulations which aren't supported yet by the DVB
API, so comment them out until support for them is added.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-sx8.c | 30 +++---
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-sx8.c 
b/drivers/media/pci/ddbridge/ddbridge-sx8.c
index c87cefa10762..4418604258d1 100644
--- a/drivers/media/pci/ddbridge/ddbridge-sx8.c
+++ b/drivers/media/pci/ddbridge/ddbridge-sx8.c
@@ -372,15 +372,31 @@ static int set_parameters(struct dvb_frontend *fe)
if (iq_mode)
ts_config = (SX8_TSCONFIG_TSHEADER | SX8_TSCONFIG_MODE_IQ);
if (iq_mode < 3) {
-   u32 flags = 3;
-   u32 mask = 0x7f;
-
-   if (p->modulation == APSK_16 ||
-   p->modulation == APSK_32) {
-   flags = 2;
+   u32 mask;
+
+   switch (p->modulation) {
+   /* uncomment whenever these modulations hit the DVB API
+*  case APSK_256:
+*  mask = 0x7f;
+*  break;
+*  case APSK_128:
+*  mask = 0x3f;
+*  break;
+*  case APSK_64:
+*  mask = 0x1f;
+*  break;
+*/
+   case APSK_32:
mask = 0x0f;
+   break;
+   case APSK_16:
+   mask = 0x07;
+   break;
+   default:
+   mask = 0x03;
+   break;
}
-   stat = start(fe, flags, mask, ts_config);
+   stat = start(fe, 3, mask, ts_config);
} else {
u32 flags = (iq_mode == 2) ? 1 : 0;
 
-- 
2.16.4



[PATCH 04/19] [media] ddbridge: evaluate the actual link when setting up the dummy tuner

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Devices supporting dummy tuner operation can exist on any link, not only
on link 0, so fix this accordingly.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 3f83415b06c7..55eb151f329e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1859,7 +1859,7 @@ static void ddb_port_probe(struct ddb_port *port)
/* Handle missing ports and ports without I2C */
 
if (dummy_tuner && !port->nr &&
-   dev->link[0].ids.device == 0x0005) {
+   dev->link[l].ids.device == 0x0005) {
port->name = "DUMMY";
port->class = DDB_PORT_TUNER;
port->type = DDB_TUNER_DUMMY;
-- 
2.16.4



[PATCH 05/19] [media] ddbridge: report I2C bus errors

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

The I2C_COMMAND response reports an error in the I2C bus communication
using bit 17. Evaluate the response more thoroughly and log an error
if an I2C problem was detected.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-i2c.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c 
b/drivers/media/pci/ddbridge/ddbridge-i2c.c
index 667340c86ea7..5a28d7611713 100644
--- a/drivers/media/pci/ddbridge/ddbridge-i2c.c
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c
@@ -73,7 +73,10 @@ static int ddb_i2c_cmd(struct ddb_i2c *i2c, u32 adr, u32 cmd)
}
return -EIO;
}
-   if (val & 0x7)
+   val &= 0x7;
+   if (val == 0x2)
+   dev_err(dev->dev, "I2C bus error\n");
+   if (val)
return -EIO;
return 0;
 }
-- 
2.16.4



[PATCH 00/19] dddvb/ddbridge updates as of 2018-06-23

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

A bunch of commits as they appeared in the dddvb upstream GIT as of
2018-06-23, mainly cleanups, cosmetics and code move in preparation for
new MCI card types, plus improvements to the existing SX8 code, ie.
DVBv5 signal statistics.

Also fixes one sparse warning as being reported by Hans' daily media_tree
build in the mxl5xx driver.

Daniel Scheller (19):
  [media] dvb-frontends/mxl5xx: add break to case DVBS2 in
get_frontend()
  [media] dvb-frontends/stv0910: cast the BER denominator shift exp to
ULL
  [media] ddbridge: probe for LNBH25 chips before attaching
  [media] ddbridge: evaluate the actual link when setting up the dummy
tuner
  [media] ddbridge: report I2C bus errors
  [media] ddbridge: remove unused MDIO defines and hwinfo member
  [media] ddbridge: link structure access cosmetics in ddb_port_probe()
  [media] ddbridge: change MCI base ID and define a SX8 ID
  [media] ddbridge/mci: update copyright year in headers
  [media] ddbridge/mci: read and report signal strength and SNR
  [media] ddbridge/mci: rename defines and fix i/q var types
  [media] ddbridge/mci: extend mci_command and mci_result structs
  [media] ddbridge/mci: store mci type and number of ports in the hwinfo
  [media] ddbridge/mci: make ddb_mci_cmd() and ddb_mci_config() public
  [media] ddbridge/mci: split MaxSX8 specific code off to ddbridge-sx8.c
  [media] ddbridge/mci: add more MCI status codes, improve MCI_SUCCESS
macro
  [media] ddbridge/sx8: disable automatic PLS code search
  [media] ddbridge/sx8: enable modulation selection in set_parameters()
  [media] ddbridge/mci: add SX8 I/Q mode remark and remove DIAG CMD
defines

 drivers/media/dvb-frontends/mxl5xx.c   |   1 +
 drivers/media/dvb-frontends/stv0910.c  |   4 +-
 drivers/media/pci/ddbridge/Makefile|   3 +-
 drivers/media/pci/ddbridge/ddbridge-core.c |  45 +--
 drivers/media/pci/ddbridge/ddbridge-hw.c   |   3 +-
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |   5 +-
 drivers/media/pci/ddbridge/ddbridge-max.c  |  18 +-
 drivers/media/pci/ddbridge/ddbridge-max.h  |   2 +-
 drivers/media/pci/ddbridge/ddbridge-mci.c  | 409 ++--
 drivers/media/pci/ddbridge/ddbridge-mci.h  | 192 ---
 drivers/media/pci/ddbridge/ddbridge-regs.h |   8 -
 drivers/media/pci/ddbridge/ddbridge-sx8.c  | 490 +
 drivers/media/pci/ddbridge/ddbridge.h  |  14 +-
 13 files changed, 718 insertions(+), 476 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-sx8.c

-- 
2.16.4



[PATCH 08/19] [media] ddbridge: change MCI base ID and define a SX8 ID

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Change the start of the MCI ID range (internally used only) to 48 and
define an ID for the SX8 card type. Use this new ID to handle device
attachment.

This change is done in preparation for support of more MCI based cards.

Picked up from the upstream dddvb GIT.

Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++--
 drivers/media/pci/ddbridge/ddbridge.h  | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 408460be00b7..68ea0ffdad2d 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1592,7 +1592,7 @@ static int dvb_input_attach(struct ddb_input *input)
if (demod_attach_dummy(input) < 0)
goto err_detach;
break;
-   case DDB_TUNER_MCI:
+   case DDB_TUNER_MCI_SX8:
if (ddb_fe_attach_mci(input) < 0)
goto err_detach;
break;
@@ -1898,7 +1898,7 @@ static void ddb_port_probe(struct ddb_port *port)
port->name = "DUAL MCI";
port->type_name = "MCI";
port->class = DDB_PORT_TUNER;
-   port->type = DDB_TUNER_MCI;
+   port->type = DDB_TUNER_MCI_SX8;
return;
}
 
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 9c645bee428a..65bd74d86ed5 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -254,7 +254,6 @@ struct ddb_port {
 #define DDB_CI_EXTERNAL_XO2_B13
 #define DDB_TUNER_DVBS_STV0910_PR 14
 #define DDB_TUNER_DVBC2T2I_SONY_P 15
-#define DDB_TUNER_MCI16
 
 #define DDB_TUNER_XO232
 #define DDB_TUNER_DVBS_STV0910   (DDB_TUNER_XO2 + 0)
@@ -264,6 +263,9 @@ struct ddb_port {
 #define DDB_TUNER_ATSC_ST(DDB_TUNER_XO2 + 4)
 #define DDB_TUNER_DVBC2T2I_SONY  (DDB_TUNER_XO2 + 5)
 
+#define DDB_TUNER_MCI48
+#define DDB_TUNER_MCI_SX8(DDB_TUNER_MCI + 0)
+
struct ddb_input  *input[2];
struct ddb_output *output;
struct dvb_ca_en50221 *en;
-- 
2.16.4



[PATCH 01/19] [media] dvb-frontends/mxl5xx: add break to case DVBS2 in get_frontend()

2018-06-23 Thread Daniel Scheller
From: Daniel Scheller 

Fix one sparse warning:

drivers/media/dvb-frontends/mxl5xx.c:731:3: warning: this statement may 
fall through [-Wimplicit-fallthrough=]

as seen in Hans' daily media_tree builds.

Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/mxl5xx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 274d8fca0763..a7d08ace11ba 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -739,6 +739,7 @@ static int get_frontend(struct dvb_frontend *fe,
default:
break;
}
+   break;
case SYS_DVBS:
switch ((enum MXL_HYDRA_MODULATION_E)
reg_data[DMD_MODULATION_SCHEME_ADDR]) {
-- 
2.16.4



[PATCH 3/3] [media] dvb-frontends/cxd2099: fix boilerplate whitespace

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

There's a superfluous whitespace in the boilerplate license text in both
.c and .h files. Fix this.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/cxd2099.c | 2 +-
 drivers/media/dvb-frontends/cxd2099.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/cxd2099.c 
b/drivers/media/dvb-frontends/cxd2099.c
index 5264e873850e..5d8884ed64ef 100644
--- a/drivers/media/dvb-frontends/cxd2099.c
+++ b/drivers/media/dvb-frontends/cxd2099.c
@@ -10,7 +10,7 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  */
 
diff --git a/drivers/media/dvb-frontends/cxd2099.h 
b/drivers/media/dvb-frontends/cxd2099.h
index 0c101bdef01d..30787095843a 100644
--- a/drivers/media/dvb-frontends/cxd2099.h
+++ b/drivers/media/dvb-frontends/cxd2099.h
@@ -10,7 +10,7 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  */
 
-- 
2.16.4



[PATCH 2/3] [media] dvb-frontends/cxd2099: add SPDX license identifier

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

As both the MODULE_LICENSE and the boilerplates are now in sync and clear
that the driver is licensed under the terms of the GPLv2-only, add a
matching SPDX license identifier tag.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/cxd2099.c | 1 +
 drivers/media/dvb-frontends/cxd2099.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/dvb-frontends/cxd2099.c 
b/drivers/media/dvb-frontends/cxd2099.c
index 42de3d0badba..5264e873850e 100644
--- a/drivers/media/dvb-frontends/cxd2099.c
+++ b/drivers/media/dvb-frontends/cxd2099.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * cxd2099.c: Driver for the Sony CXD2099AR Common Interface Controller
  *
diff --git a/drivers/media/dvb-frontends/cxd2099.h 
b/drivers/media/dvb-frontends/cxd2099.h
index ec1910dec3f3..0c101bdef01d 100644
--- a/drivers/media/dvb-frontends/cxd2099.h
+++ b/drivers/media/dvb-frontends/cxd2099.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * cxd2099.h: Driver for the Sony CXD2099AR Common Interface Controller
  *
-- 
2.16.4



[PATCH 0/3] cxd2099: cleanup licensing

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

Upstream committed a change to the dddvb driver package ([1]) that makes
things clear everything is licensed under the terms of the GPLv2-only.
So, apply the MODULE_LICENSE change to cxd2099 and, as things are sorted
now, apply SPDX license identifiers (and fix two spurious whitespaces).

Split from the series that touches all other Digital Devices drivers
since Jasmin is the maintainer for the cxd2099 driver.

Ralph/Manfred: Although all license related things should be clear by
now, please be so kind and send Acks (or complaints, if any) on these
patches so we can finally get rid of any mismatches in the in-kernel
drivers.

[1] 
https://github.com/DigitalDevices/dddvb/commit/3db30defab4bd5429f6563b084a215b83da01ea0

Daniel Scheller (3):
  [media] dvb-frontends/cxd2099: fix MODULE_LICENSE to 'GPL v2'
  [media] dvb-frontends/cxd2099: add SPDX license identifier
  [media] dvb-frontends/cxd2099: fix boilerplate whitespace

 drivers/media/dvb-frontends/cxd2099.c | 5 +++--
 drivers/media/dvb-frontends/cxd2099.h | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

-- 
2.16.4



[PATCH 1/3] [media] dvb-frontends/cxd2099: fix MODULE_LICENSE to 'GPL v2'

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

In commit 3db30defab4b ("use correct MODULE_LINCESE for GPL v2 only
according to notice in header") in the upstream repository for the
mentioned driver at https://github.com/DigitalDevices/dddvb.git, the
MODULE_LICENSE was fixed to "GPL v2" and is now in sync with the GPL
copyright boilerplate. Apply this change to the kernel tree driver
aswell.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/cxd2099.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/cxd2099.c 
b/drivers/media/dvb-frontends/cxd2099.c
index 4a0ce3037fd6..42de3d0badba 100644
--- a/drivers/media/dvb-frontends/cxd2099.c
+++ b/drivers/media/dvb-frontends/cxd2099.c
@@ -701,4 +701,4 @@ module_i2c_driver(cxd2099_driver);
 
 MODULE_DESCRIPTION("Sony CXD2099AR Common Interface controller driver");
 MODULE_AUTHOR("Ralph Metzler");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
-- 
2.16.4



[PATCH v3 8/9] [media] dvb-frontends/stv6111: cleanup and fix licensing boilerplates

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

The stv6111.h doesn't carry any header nor any licensing boilerplate at
all, so copy this from the main driver file stv6111.c. While at it,
apply the usual whitespace/blank line cleanup.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv6111.c |  3 +--
 drivers/media/dvb-frontends/stv6111.h | 15 +++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv6111.c 
b/drivers/media/dvb-frontends/stv6111.c
index 25208a120cb7..88c0cf4c5011 100644
--- a/drivers/media/dvb-frontends/stv6111.c
+++ b/drivers/media/dvb-frontends/stv6111.c
@@ -9,9 +9,8 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
  */
 
 #include 
diff --git a/drivers/media/dvb-frontends/stv6111.h 
b/drivers/media/dvb-frontends/stv6111.h
index 5bc1228dc9bd..809e62361a91 100644
--- a/drivers/media/dvb-frontends/stv6111.h
+++ b/drivers/media/dvb-frontends/stv6111.h
@@ -1,3 +1,18 @@
+/*
+ * Driver for the ST STV6111 tuner
+ *
+ * Copyright (C) 2014 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.
+ */
+
 #ifndef _STV6111_H_
 #define _STV6111_H_
 
-- 
2.16.4



[PATCH v3 6/9] [media] dvb-frontends/stv0910: cleanup and fix licensing boilerplates

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

The stv0910.h doesn't carry any header nor any licensing boilerplate at
all, so copy this from the main driver file stv0910.c. While at it,
apply the usual whitespace/blank line cleanup aswell.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0910.c  |  2 +-
 drivers/media/dvb-frontends/stv0910.h  | 17 +
 drivers/media/dvb-frontends/stv0910_regs.h |  2 +-
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 8d72de0ff5b0..16f73c16ac61 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -11,7 +11,7 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
  */
 
diff --git a/drivers/media/dvb-frontends/stv0910.h 
b/drivers/media/dvb-frontends/stv0910.h
index f37171b7a2de..c3985bee749f 100644
--- a/drivers/media/dvb-frontends/stv0910.h
+++ b/drivers/media/dvb-frontends/stv0910.h
@@ -1,3 +1,20 @@
+/*
+ * Driver for the ST STV0910 DVB-S/S2 demodulator.
+ *
+ * Copyright (C) 2014-2015 Ralph Metzler 
+ * Marcus Metzler 
+ * 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.
+ */
+
 #ifndef _STV0910_H_
 #define _STV0910_H_
 
diff --git a/drivers/media/dvb-frontends/stv0910_regs.h 
b/drivers/media/dvb-frontends/stv0910_regs.h
index f0eb915090bd..4440892df61f 100644
--- a/drivers/media/dvb-frontends/stv0910_regs.h
+++ b/drivers/media/dvb-frontends/stv0910_regs.h
@@ -1,7 +1,7 @@
 /*
  * @DVB-S/DVB-S2 STMicroelectronics STV0900 register definitions
  * Author Manfred Voelkel, August 2013
- * (c) 2013 Digital Devices GmbH Germany.  All rights reserved
+ * (c) 2013 Digital Devices GmbH Germany. All rights reserved
  *
  * ===
  * Registers Declaration (Internal ST, All Applications )
-- 
2.16.4



[PATCH v3 4/9] [media] dvb-frontends/mxl5xx: cleanup and fix licensing boilerplates

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

mxl5xx.h doesn't carry any licensing boilerplate at all right now, so copy
the boilerplate over from the main driver file mxl5xx.c. Also, mxl5xx_defs
is missing a part of the licensing boilerplate text, so add it. While at
it, fix up some minor whitespace and blank line issues.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/mxl5xx.c  |  3 +--
 drivers/media/dvb-frontends/mxl5xx.h  | 21 +
 drivers/media/dvb-frontends/mxl5xx_defs.h |  5 +
 drivers/media/dvb-frontends/mxl5xx_regs.h |  3 +--
 4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 1067701bdd06..323fd73d6e1e 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -15,9 +15,8 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
  */
 
 #include 
diff --git a/drivers/media/dvb-frontends/mxl5xx.h 
b/drivers/media/dvb-frontends/mxl5xx.h
index ad4c21846800..2ee821b15693 100644
--- a/drivers/media/dvb-frontends/mxl5xx.h
+++ b/drivers/media/dvb-frontends/mxl5xx.h
@@ -1,3 +1,24 @@
+/*
+ * Driver for the MaxLinear MxL5xx family of tuners/demods
+ *
+ * Copyright (C) 2014-2015 Ralph Metzler 
+ * Marcus Metzler 
+ * developed for Digital Devices GmbH
+ *
+ * based on code:
+ * Copyright (c) 2011-2013 MaxLinear, Inc. All rights reserved
+ * which was released under GPL V2
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, 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.
+ */
+
 #ifndef _MXL5XX_H_
 #define _MXL5XX_H_
 
diff --git a/drivers/media/dvb-frontends/mxl5xx_defs.h 
b/drivers/media/dvb-frontends/mxl5xx_defs.h
index fd9e61e0188f..fd5c0f5b27ba 100644
--- a/drivers/media/dvb-frontends/mxl5xx_defs.h
+++ b/drivers/media/dvb-frontends/mxl5xx_defs.h
@@ -10,6 +10,11 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * version 2, 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.
  */
 
 enum MXL_BOOL_E {
diff --git a/drivers/media/dvb-frontends/mxl5xx_regs.h 
b/drivers/media/dvb-frontends/mxl5xx_regs.h
index 5001dafe1ba8..dacc1fdf4c7b 100644
--- a/drivers/media/dvb-frontends/mxl5xx_regs.h
+++ b/drivers/media/dvb-frontends/mxl5xx_regs.h
@@ -9,11 +9,10 @@
  *
  * 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.
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
details.
  *
  * This program may alternatively be licensed under a proprietary license from
  * MaxLinear, Inc.
- *
  */
 
 #ifndef __MXL58X_REGISTERS_H__
-- 
2.16.4



[PATCH v3 0/9] DD drivers: cleanup licensing

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

Upstream committed a change to the dddvb driver package ([1]) that makes
things clear everything is licensed under the terms of the GPLv2-only.
So, apply the MODULE_LICENSE change to ddbridge, mxl5xx, stv0910 and
stv6111, and, as things are sorted now, apply SPDX license identifiers,
add missing header boilerplates in the DVB frontend drivers and fix up
a few cosmetics throughout the boilerplates.

One note re checkpatch and the order of the patches: I wanted to add
missing boilerplates where needed first before adding SPDX tags, so
checkpatch complains missing/malformed SPDX tags on those patches. Also,
I didn't want to touch the mxl5xx_regs more than needed, so checkpatch
moans about >80 columns in that patch/file.

Ralph/Manfred: Although all license related things should be clear by
now, please be so kind and send Acks (or complaints, if any) on these
patches so we can finally get rid of any mismatches in the in-kernel
drivers.

Changed in v3:
* (there was only one version posted so far but this is nonetheless
  the third iteration overall)
* Split up changes into more patches as requested by GregKH
* Note the change in the upstream driver package

[1] 
https://github.com/DigitalDevices/dddvb/commit/3db30defab4bd5429f6563b084a215b83da01ea0

Daniel Scheller (9):
  [media] mxl5xx/stv0910/stv6111/ddbridge: fix MODULE_LICENSE to 'GPL
v2'
  [media] ddbridge: add SPDX license identifiers
  [media] ddbridge: header/boilerplate cleanups and cosmetics
  [media] dvb-frontends/mxl5xx: cleanup and fix licensing boilerplates
  [media] dvb-frontends/mxl5xx: add SPDX license identifier
  [media] dvb-frontends/stv0910: cleanup and fix licensing boilerplates
  [media] dvb-frontends/stv0910: add SPDX license identifier
  [media] dvb-frontends/stv6111: cleanup and fix licensing boilerplates
  [media] dvb-frontends/stv6111: add SPDX license identifier

 drivers/media/dvb-frontends/mxl5xx.c   |  6 +++---
 drivers/media/dvb-frontends/mxl5xx.h   | 22 ++
 drivers/media/dvb-frontends/mxl5xx_defs.h  |  6 ++
 drivers/media/dvb-frontends/mxl5xx_regs.h  |  4 ++--
 drivers/media/dvb-frontends/stv0910.c  |  5 +++--
 drivers/media/dvb-frontends/stv0910.h  | 18 ++
 drivers/media/dvb-frontends/stv0910_regs.h |  3 ++-
 drivers/media/dvb-frontends/stv6111.c  |  6 +++---
 drivers/media/dvb-frontends/stv6111.h  | 16 
 drivers/media/pci/ddbridge/ddbridge-ci.c   |  6 ++
 drivers/media/pci/ddbridge/ddbridge-ci.h   |  6 ++
 drivers/media/pci/ddbridge/ddbridge-core.c |  8 ++--
 drivers/media/pci/ddbridge/ddbridge-hw.c   |  4 ++--
 drivers/media/pci/ddbridge/ddbridge-hw.h   |  4 ++--
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |  4 ++--
 drivers/media/pci/ddbridge/ddbridge-i2c.h  |  6 +++---
 drivers/media/pci/ddbridge/ddbridge-io.h   |  4 ++--
 drivers/media/pci/ddbridge/ddbridge-main.c |  6 +++---
 drivers/media/pci/ddbridge/ddbridge-max.c  |  4 ++--
 drivers/media/pci/ddbridge/ddbridge-max.h  |  4 ++--
 drivers/media/pci/ddbridge/ddbridge-regs.h |  7 ++-
 drivers/media/pci/ddbridge/ddbridge.h  |  7 ++-
 22 files changed, 103 insertions(+), 53 deletions(-)

-- 
2.16.4



[PATCH v3 3/9] [media] ddbridge: header/boilerplate cleanups and cosmetics

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

Cleanup whitespaces and blank lines, remove wrong links to
http://www.gnu.org/copyleft/gpl.html (the driver is licensed under the
terms of GPLv2, but the link points to a copy of the GPLv3), and fix
the filename reference in ddbridge-i2c.h.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-ci.c   | 5 +
 drivers/media/pci/ddbridge/ddbridge-ci.h   | 5 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 7 +--
 drivers/media/pci/ddbridge/ddbridge-hw.c   | 3 +--
 drivers/media/pci/ddbridge/ddbridge-hw.h   | 3 +--
 drivers/media/pci/ddbridge/ddbridge-i2c.c  | 3 +--
 drivers/media/pci/ddbridge/ddbridge-i2c.h  | 5 ++---
 drivers/media/pci/ddbridge/ddbridge-io.h   | 3 +--
 drivers/media/pci/ddbridge/ddbridge-main.c | 3 +--
 drivers/media/pci/ddbridge/ddbridge-max.c  | 3 +--
 drivers/media/pci/ddbridge/ddbridge-max.h  | 3 +--
 drivers/media/pci/ddbridge/ddbridge-regs.h | 6 +-
 drivers/media/pci/ddbridge/ddbridge.h  | 6 +-
 13 files changed, 14 insertions(+), 41 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c 
b/drivers/media/pci/ddbridge/ddbridge-ci.c
index 23b0e7d69e94..21cb7fc216ac 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.c
@@ -12,11 +12,8 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
- * To obtain the license, point your browser to
- * http://www.gnu.org/copyleft/gpl.html
  */
 
 #include "ddbridge.h"
diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.h 
b/drivers/media/pci/ddbridge/ddbridge-ci.h
index c482132692f8..f2fb2b670165 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.h
@@ -12,11 +12,8 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
- * To obtain the license, point your browser to
- * http://www.gnu.org/copyleft/gpl.html
  */
 
 #ifndef __DDBRIDGE_CI_H__
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 3a8bb652de56..c543e0ee7c76 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -6,19 +6,14 @@
  * Marcus Metzler 
  * Ralph Metzler 
  *
- *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
- * To obtain the license, point your browser to
- * http://www.gnu.org/copyleft/gpl.html
  */
 
 #include 
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c 
b/drivers/media/pci/ddbridge/ddbridge-hw.c
index 39c2c1750b05..c8160f523ea1 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.c
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -12,9 +12,8 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
  */
 
 #include "ddbridge.h"
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.h 
b/drivers/media/pci/ddbridge/ddbridge-hw.h
index 72fd59e8c7c7..fe4ef7e080a4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.h
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.h
@@ -12,9 +12,8 @@
  *
  * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
  */
 
 #ifndef _DDBRIDGE_HW_H_
diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c 
b/drivers/media/pci/ddbridge/ddbridge-i2c.c
index f7c4a88e3e66..822f9704190b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-i2c.c
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c
@@ -12,9 +12,8 @@
  *
  * This program is distributed in the hope th

[PATCH v3 9/9] [media] dvb-frontends/stv6111: add SPDX license identifier

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

As it is clear that the driver is licensed under the terms of GPLv2-only
by now, add a matching SPDX license identifier to all driver files.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv6111.c | 1 +
 drivers/media/dvb-frontends/stv6111.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv6111.c 
b/drivers/media/dvb-frontends/stv6111.c
index 88c0cf4c5011..4185441fa78b 100644
--- a/drivers/media/dvb-frontends/stv6111.c
+++ b/drivers/media/dvb-frontends/stv6111.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Driver for the ST STV6111 tuner
  *
diff --git a/drivers/media/dvb-frontends/stv6111.h 
b/drivers/media/dvb-frontends/stv6111.h
index 809e62361a91..8823eb326784 100644
--- a/drivers/media/dvb-frontends/stv6111.h
+++ b/drivers/media/dvb-frontends/stv6111.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Driver for the ST STV6111 tuner
  *
-- 
2.16.4



[PATCH v3 7/9] [media] dvb-frontends/stv0910: add SPDX license identifier

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

As it is clear that the driver is licensed under the terms of GPLv2-only
by now, add a matching SPDX license identifier to all driver files.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/stv0910.c  | 1 +
 drivers/media/dvb-frontends/stv0910.h  | 1 +
 drivers/media/dvb-frontends/stv0910_regs.h | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 16f73c16ac61..a81d3cc0acae 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Driver for the ST STV0910 DVB-S/S2 demodulator.
  *
diff --git a/drivers/media/dvb-frontends/stv0910.h 
b/drivers/media/dvb-frontends/stv0910.h
index c3985bee749f..19b48409e050 100644
--- a/drivers/media/dvb-frontends/stv0910.h
+++ b/drivers/media/dvb-frontends/stv0910.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Driver for the ST STV0910 DVB-S/S2 demodulator.
  *
diff --git a/drivers/media/dvb-frontends/stv0910_regs.h 
b/drivers/media/dvb-frontends/stv0910_regs.h
index 4440892df61f..12ae86fae965 100644
--- a/drivers/media/dvb-frontends/stv0910_regs.h
+++ b/drivers/media/dvb-frontends/stv0910_regs.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * @DVB-S/DVB-S2 STMicroelectronics STV0900 register definitions
  * Author Manfred Voelkel, August 2013
-- 
2.16.4



[PATCH v3 5/9] [media] dvb-frontends/mxl5xx: add SPDX license identifier

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

As it is clear that the driver is licensed under the terms of GPLv2-only
by now, add a matching SPDX license identifier to all driver files.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/mxl5xx.c  | 1 +
 drivers/media/dvb-frontends/mxl5xx.h  | 1 +
 drivers/media/dvb-frontends/mxl5xx_defs.h | 1 +
 drivers/media/dvb-frontends/mxl5xx_regs.h | 1 +
 4 files changed, 4 insertions(+)

diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 323fd73d6e1e..922449f940a0 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Driver for the MaxLinear MxL5xx family of tuners/demods
  *
diff --git a/drivers/media/dvb-frontends/mxl5xx.h 
b/drivers/media/dvb-frontends/mxl5xx.h
index 2ee821b15693..5113759d7fb7 100644
--- a/drivers/media/dvb-frontends/mxl5xx.h
+++ b/drivers/media/dvb-frontends/mxl5xx.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Driver for the MaxLinear MxL5xx family of tuners/demods
  *
diff --git a/drivers/media/dvb-frontends/mxl5xx_defs.h 
b/drivers/media/dvb-frontends/mxl5xx_defs.h
index fd5c0f5b27ba..295a2d75b5a7 100644
--- a/drivers/media/dvb-frontends/mxl5xx_defs.h
+++ b/drivers/media/dvb-frontends/mxl5xx_defs.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Defines for the Maxlinear MX58x family of tuners/demods
  *
diff --git a/drivers/media/dvb-frontends/mxl5xx_regs.h 
b/drivers/media/dvb-frontends/mxl5xx_regs.h
index dacc1fdf4c7b..1b9715691b3c 100644
--- a/drivers/media/dvb-frontends/mxl5xx_regs.h
+++ b/drivers/media/dvb-frontends/mxl5xx_regs.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2011-2013 MaxLinear, Inc. All rights reserved
  *
-- 
2.16.4



[PATCH v3 2/9] [media] ddbridge: add SPDX license identifiers

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

Since the boilerplates and MODULE_LICENSE are now in sync regarding the
used license (GPL v2 only), add a matching GPLv2 SPDX license identifier
to all files of the ddbridge driver.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/pci/ddbridge/ddbridge-ci.c   | 1 +
 drivers/media/pci/ddbridge/ddbridge-ci.h   | 1 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 1 +
 drivers/media/pci/ddbridge/ddbridge-hw.c   | 1 +
 drivers/media/pci/ddbridge/ddbridge-hw.h   | 1 +
 drivers/media/pci/ddbridge/ddbridge-i2c.c  | 1 +
 drivers/media/pci/ddbridge/ddbridge-i2c.h  | 1 +
 drivers/media/pci/ddbridge/ddbridge-io.h   | 1 +
 drivers/media/pci/ddbridge/ddbridge-main.c | 1 +
 drivers/media/pci/ddbridge/ddbridge-max.c  | 1 +
 drivers/media/pci/ddbridge/ddbridge-max.h  | 1 +
 drivers/media/pci/ddbridge/ddbridge-regs.h | 1 +
 drivers/media/pci/ddbridge/ddbridge.h  | 1 +
 13 files changed, 13 insertions(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.c 
b/drivers/media/pci/ddbridge/ddbridge-ci.c
index cfe23d02e561..23b0e7d69e94 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ddbridge-ci.c: Digital Devices bridge CI (DuoFlex, CI Bridge) support
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-ci.h 
b/drivers/media/pci/ddbridge/ddbridge-ci.h
index 35a39182dd83..c482132692f8 100644
--- a/drivers/media/pci/ddbridge/ddbridge-ci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-ci.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * ddbridge-ci.h: Digital Devices bridge CI (DuoFlex, CI Bridge) support
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index d5b0d1eaf3ad..3a8bb652de56 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ddbridge-core.c: Digital Devices bridge core functions
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c 
b/drivers/media/pci/ddbridge/ddbridge-hw.c
index 1d3ee6accdd5..39c2c1750b05 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.c
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ddbridge-hw.c: Digital Devices bridge hardware maps
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.h 
b/drivers/media/pci/ddbridge/ddbridge-hw.h
index 7c142419419c..72fd59e8c7c7 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.h
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * ddbridge-hw.h: Digital Devices bridge hardware maps
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.c 
b/drivers/media/pci/ddbridge/ddbridge-i2c.c
index 667340c86ea7..f7c4a88e3e66 100644
--- a/drivers/media/pci/ddbridge/ddbridge-i2c.c
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ddbridge-i2c.c: Digital Devices bridge i2c driver
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-i2c.h 
b/drivers/media/pci/ddbridge/ddbridge-i2c.h
index 7ed220506c05..996462e51eab 100644
--- a/drivers/media/pci/ddbridge/ddbridge-i2c.h
+++ b/drivers/media/pci/ddbridge/ddbridge-i2c.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * ddbridge-i2c.c: Digital Devices bridge i2c driver
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-io.h 
b/drivers/media/pci/ddbridge/ddbridge-io.h
index b3646c04f1a7..c458df31cc43 100644
--- a/drivers/media/pci/ddbridge/ddbridge-io.h
+++ b/drivers/media/pci/ddbridge/ddbridge-io.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * ddbridge-io.h: Digital Devices bridge I/O inline functions
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 6f3ea927bde5..419a30bd9c21 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ddbridge.c: Digital Devices PCIe bridge driver
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c 
b/drivers/media/pci/ddbridge/ddbridge-max.c
index 739e4b444cf4..dc6276b0d10e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.c
+++ b/drivers/media/pci/ddbridge/ddbridge-max.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * ddbridge-max.c: Digital Devices bridge MAX card support
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h 
b/drivers/media/pci/ddbridge/ddbridge-max.h
index 82efc53baa94..cff35de3d173 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.h
+++ b/drivers/media/pci/ddbridge/ddbridge-max.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * ddbridge-max.h: Digital Devices bridge MAX card support
  *
diff --git a/drivers/media/pci/ddbridge/ddbridge-regs.h 
b/drivers/media/pci/ddbridge/ddbridge

[PATCH v3 1/9] [media] mxl5xx/stv0910/stv6111/ddbridge: fix MODULE_LICENSE to 'GPL v2'

2018-06-19 Thread Daniel Scheller
From: Daniel Scheller 

In commit 3db30defab4b ("use correct MODULE_LINCESE for GPL v2 only
according to notice in header") in the upstream repository for the
mentioned four drivers at https://github.com/DigitalDevices/dddvb.git
(plus a few more which aren't part of the mainline kernel tree), the
MODULE_LICENSE was fixed to "GPL v2" and are now in sync with the
GPL copyright boilerplate. Apply this change to the kernel tree
drivers aswell.

Cc: Ralph Metzler 
Cc: Manfred Voelkel 
Signed-off-by: Daniel Scheller 
---
 drivers/media/dvb-frontends/mxl5xx.c   | 2 +-
 drivers/media/dvb-frontends/stv0910.c  | 2 +-
 drivers/media/dvb-frontends/stv6111.c  | 2 +-
 drivers/media/pci/ddbridge/ddbridge-main.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
b/drivers/media/dvb-frontends/mxl5xx.c
index 274d8fca0763..1067701bdd06 100644
--- a/drivers/media/dvb-frontends/mxl5xx.c
+++ b/drivers/media/dvb-frontends/mxl5xx.c
@@ -1895,4 +1895,4 @@ EXPORT_SYMBOL_GPL(mxl5xx_attach);
 
 MODULE_DESCRIPTION("MaxLinear MxL5xx DVB-S/S2 tuner-demodulator driver");
 MODULE_AUTHOR("Ralph and Marcus Metzler, Metzler Brothers Systementwicklung 
GbR");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 41444fa1c0bb..8d72de0ff5b0 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1841,4 +1841,4 @@ EXPORT_SYMBOL_GPL(stv0910_attach);
 
 MODULE_DESCRIPTION("ST STV0910 multistandard frontend driver");
 MODULE_AUTHOR("Ralph and Marcus Metzler, Manfred Voelkel");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/dvb-frontends/stv6111.c 
b/drivers/media/dvb-frontends/stv6111.c
index 9b715b6fe152..25208a120cb7 100644
--- a/drivers/media/dvb-frontends/stv6111.c
+++ b/drivers/media/dvb-frontends/stv6111.c
@@ -688,4 +688,4 @@ EXPORT_SYMBOL_GPL(stv6111_attach);
 
 MODULE_DESCRIPTION("ST STV6111 satellite tuner driver");
 MODULE_AUTHOR("Ralph Metzler, Manfred Voelkel");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index f4748cfd904b..6f3ea927bde5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -318,5 +318,5 @@ module_exit(module_exit_ddbridge);
 
 MODULE_DESCRIPTION("Digital Devices PCIe Bridge");
 MODULE_AUTHOR("Ralph and Marcus Metzler, Metzler Brothers Systementwicklung 
GbR");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
 MODULE_VERSION(DDBRIDGE_VERSION);
-- 
2.16.4



[PATCH v3 3/3] [media] ddbridge: implement IOCTL handling

2018-05-12 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

This patch adds back the IOCTL API/functionality which is present in the
upstream dddvb driver package. In comparison, the IOCTL handler has been
factored to a separate object (and with that, some functionality from
-core, such as reg_wait() and ddb_flashio() has been moved there aswell).
The IOCTLs were defined in an include in include/uapi/linux/ previously
and being reused here.

The main purpose at the moment is to enable the mainline driver to handle
FPGA firmware updates of all cards supported by the ddbridge driver, which
gets even more important since the introduction of the MaxSX8 support
(this card basically implements the I2C demod/tuner drivers which are used
normally in FPGA, so any fixes need to be flashed into the card), and
the recent firmware releases for the CineS2v7 and Octopus CI S2 series
that not only carry bugfixes, but also enables support for higher
bandwidth transponders.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/Makefile |   3 +-
 drivers/media/pci/ddbridge/ddbridge-core.c  | 111 +
 drivers/media/pci/ddbridge/ddbridge-ioctl.c | 179 
 drivers/media/pci/ddbridge/ddbridge-ioctl.h |  32 +
 4 files changed, 215 insertions(+), 110 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ioctl.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ioctl.h

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index 9b9e35f171b7..3563a3e3d7f9 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -4,7 +4,8 @@
 #
 
 ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \
-   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o ddbridge-mci.o
+   ddbridge-hw.o ddbridge-i2c.o ddbridge-ioctl.o ddbridge-max.o \
+   ddbridge-mci.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 377269c64449..cc0db7b718b1 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -40,6 +40,7 @@
 #include "ddbridge-max.h"
 #include "ddbridge-ci.h"
 #include "ddbridge-io.h"
+#include "ddbridge-ioctl.h"
 
 #include "tda18271c2dd.h"
 #include "stv6110x.h"
@@ -2547,112 +2548,14 @@ irqreturn_t ddb_irq_handler(int irq, void *dev_id)
 //
 //
 
-static int reg_wait(struct ddb *dev, u32 reg, u32 bit)
-{
-   u32 count = 0;
-
-   while (safe_ddbreadl(dev, reg) & bit) {
-   ndelay(10);
-   if (++count == 100)
-   return -1;
-   }
-   return 0;
-}
-
-static int flashio(struct ddb *dev, u32 lnr, u8 *wbuf, u32 wlen, u8 *rbuf,
-  u32 rlen)
-{
-   u32 data, shift;
-   u32 tag = DDB_LINK_TAG(lnr);
-   struct ddb_link *link = >link[lnr];
-
-   mutex_lock(>flash_mutex);
-   if (wlen > 4)
-   ddbwritel(dev, 1, tag | SPI_CONTROL);
-   while (wlen > 4) {
-   /* FIXME: check for big-endian */
-   data = swab32(*(u32 *)wbuf);
-   wbuf += 4;
-   wlen -= 4;
-   ddbwritel(dev, data, tag | SPI_DATA);
-   if (reg_wait(dev, tag | SPI_CONTROL, 4))
-   goto fail;
-   }
-   if (rlen)
-   ddbwritel(dev, 0x0001 | ((wlen << (8 + 3)) & 0x1f00),
- tag | SPI_CONTROL);
-   else
-   ddbwritel(dev, 0x0003 | ((wlen << (8 + 3)) & 0x1f00),
- tag | SPI_CONTROL);
-
-   data = 0;
-   shift = ((4 - wlen) * 8);
-   while (wlen) {
-   data <<= 8;
-   data |= *wbuf;
-   wlen--;
-   wbuf++;
-   }
-   if (shift)
-   data <<= shift;
-   ddbwritel(dev, data, tag | SPI_DATA);
-   if (reg_wait(dev, tag | SPI_CONTROL, 4))
-   goto fail;
-
-   if (!rlen) {
-   ddbwritel(dev, 0, tag | SPI_CONTROL);
-   goto exit;
-   }
-   if (rlen > 4)
-   ddbwritel(dev, 1, tag | SPI_CONTROL);
-
-   while (rlen > 4) {
-   ddbwritel(dev, 0x, tag | SPI_DATA);
-   if (reg_wait(dev, tag | SPI_CONTROL, 4))
-   goto fail;
-   data = ddbreadl(dev, tag | SPI_DATA);
-   *(u32 *)rbuf = swab32(data);
-   rbuf += 4;
-   rlen -= 4;
-   }
-   ddbwritel(dev, 0x0003 | ((rlen << (8 + 3)) & 0x1F00),
- tag | SPI_CONTROL);
-   ddbwritel(dev, 0xf

[PATCH v3 1/3] Documentation: ioctl-number: add ddbridge IOCTLs

2018-05-12 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

drivers/media/pci/ddbridge exposes a few IOCTLs which are used by userspace
utilities to ie. update PCIe card's FPGA firmware.

The IOCTLs chosen are in the range 0xDD/0xE0 up to 0xDD/0xFF, with 0xDD as
sort of gimmick for "Digital Devices". To not conflict with the zfpc driver
the upper range (0xE0-0xFF) is used. It is not clear if and which IOCTL
numbers the zfpc driver really uses, from reading the sources at
drivers/s390/scsi/ I couldn't really determine if IOCTLs are in use at all.
Maybe the S390 maintainers can double-check or comment, thus Cc linux-s390.

The upstream dddvb driver currently exposes 12 IOCTLs from which we're
going to handle two at the moment (DDB_FLASHIO and DDB_ID), which is all
that's required to perform the FPGA update on this hardware. The
"reservation" of 32 IDs may seem way too much in this regard, however,
we'd like to be able to stay compatible with the upstream out-of-tree
driver as much as possible, so should any of the remaining 10 IOCTLs be
required at any time (or even more, should upstream add more in the
future), we can just add them into this range without any hassles or
without creating conflicts anywhere.

Cc: linux-...@vger.kernel.org
Cc: linux-s...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 Documentation/ioctl/ioctl-number.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/ioctl/ioctl-number.txt 
b/Documentation/ioctl/ioctl-number.txt
index 84bb74dcae12..feac1b56900b 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -334,6 +334,7 @@ Code  Seq#(hex) Include FileComments
 0xDB   00-0F   drivers/char/mwave/mwavepub.h
 0xDD   00-3F   ZFCP device driver  see drivers/s390/scsi/
<mailto:aherr...@de.ibm.com>
+0xDD   E0-FF   linux/ddbridge-ioctl.h
 0xE5   00-3F   linux/fuse.h
 0xEC   00-01   drivers/platform/chrome/cros_ec_dev.h   ChromeOS EC driver
 0xF3   00-3F   drivers/usb/misc/sisusbvga/sisusb.h sisfb (in development)
-- 
2.16.1



[PATCH v3 2/3] [media] ddbridge: uAPI header for IOCTL definitions and related data structs

2018-05-12 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Add a uAPI header to define the IOCTLs and the related data structs used by
ddbridge, which currently are IOCTL_DDB_FLASHIO and IOCTL_DDB_IO. The
header can be included by userspace applications directly to make use of
the IOCTLs, and they even should use this header to keep things matching
with the kernel driver.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 MAINTAINERS |  1 +
 include/uapi/linux/ddbridge-ioctl.h | 61 +
 2 files changed, 62 insertions(+)
 create mode 100644 include/uapi/linux/ddbridge-ioctl.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a919a84d344..6b7da989fbed 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8710,6 +8710,7 @@ W:https://linuxtv.org
 T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/pci/ddbridge/*
+F: include/uapi/linux/ddbridge-ioctl.h
 
 MEDIA DRIVERS FOR FREESCALE IMX
 M: Steve Longerbeam <slongerb...@gmail.com>
diff --git a/include/uapi/linux/ddbridge-ioctl.h 
b/include/uapi/linux/ddbridge-ioctl.h
new file mode 100644
index ..5b28a797da41
--- /dev/null
+++ b/include/uapi/linux/ddbridge-ioctl.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * ddbridge-ioctl.h: Digital Devices bridge IOCTL API
+ *
+ * Copyright (C) 2010-2017 Digital Devices GmbH
+ * Ralph Metzler <r...@metzlerbros.de>
+ * Marcus Metzler <m...@metzlerbros.de>
+ *
+ * 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.
+ */
+
+#ifndef __LINUX_DDBRIDGE_IOCTL_H__
+#define __LINUX_DDBRIDGE_IOCTL_H__
+
+#include 
+#include 
+
+/**/
+
+#define DDB_IOCTL_MAGIC0xDD
+#define DDB_IOCTL_SEQIDX   0xE0
+
+/* DDB_IOCTL_FLASHIO */
+struct ddb_flashio {
+   /* write_*: userspace -> flash */
+   __user __u8 *write_buf;
+   __u32write_len;
+   /* read_*: flash -> userspace */
+   __user __u8 *read_buf;
+   __u32read_len;
+   /* card/addon link */
+   __u32link;
+};
+
+/* DDB_IOCTL_ID */
+struct ddb_id {
+   /* card/PCI device data, FPGA/regmap info */
+   __u16 vendor;
+   __u16 device;
+   __u16 subvendor;
+   __u16 subdevice;
+   __u32 hw;
+   __u32 regmap;
+};
+
+/* IOCTLs */
+#define DDB_IOCTL_FLASHIO \
+   _IOWR(DDB_IOCTL_MAGIC, (DDB_IOCTL_SEQIDX + 0x00), struct ddb_flashio)
+#define DDB_IOCTL_ID \
+   _IOR(DDB_IOCTL_MAGIC,  (DDB_IOCTL_SEQIDX + 0x03), struct ddb_id)
+
+/**/
+
+#endif /* __LINUX_DDBRIDGE_IOCTL_H__ */
-- 
2.16.1



[PATCH v3 0/3] IOCTLs in ddbridge

2018-05-12 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Third iteration of the IOCTL patches for ddbridge, split into multiple
patches:

Patch 1 just adds the reservation/information of the used IOCTLs into
ioctl-numbers.txt in the Docs dir. Doc, s390 and LKML are Cc'ed on
this patch.

Patch 2 adds the header which defines the IOCTLs in include/uapi/ so
userspace applications can directly reuse the IOCTL definitions by
including this file.

Patch 3 (re)implements the IOCTL handling into ddbridge. This is
basically code that was there since literally forever, but had to be
removed along with the initial ddbridge-0.9.x bump.

The whole functionality gets more important these days since ie. the
new MaxSX8 cards may require updating from time to time since these
cards implement the demod/tuner communication in their FPGA (which
normally I2C drivers exist for). Also, the CineS2v7 and derivatives
received some important updates and the possibility to receive higher
bitrate transponders these days, so users should be able to update
their cards.

Changes since the last versions:
- Docs, headers and code split apart and sent out separately to
  the subsystems.
- Only the two absolutely necessary IOCTLs (DDB_FLASHIO and DDB_ID)
  are implemented for now.

Daniel Scheller (3):
  Documentation: ioctl-number: add ddbridge IOCTLs
  [media] ddbridge: uAPI header for IOCTL definitions and related data
structs
  [media] ddbridge: implement IOCTL handling

 Documentation/ioctl/ioctl-number.txt|   1 +
 MAINTAINERS |   1 +
 drivers/media/pci/ddbridge/Makefile |   3 +-
 drivers/media/pci/ddbridge/ddbridge-core.c  | 111 +
 drivers/media/pci/ddbridge/ddbridge-ioctl.c | 179 
 drivers/media/pci/ddbridge/ddbridge-ioctl.h |  32 +
 include/uapi/linux/ddbridge-ioctl.h |  61 ++
 7 files changed, 278 insertions(+), 110 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ioctl.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-ioctl.h
 create mode 100644 include/uapi/linux/ddbridge-ioctl.h

-- 
2.16.1



Re: [PATCH][media-next] media: ddbridge: avoid out-of-bounds write on array demod_in_use

2018-05-09 Thread Daniel Scheller
Hi Colin,

Am Tue, 8 May 2018 11:39:56 +0100
schrieb Colin Ian King <colin.k...@canonical.com>:

> On 08/05/18 11:38, Daniel Scheller wrote:
> > Hi Colin,
> > 
> > Am Tue,  8 May 2018 00:08:42 +0100
> > schrieb Colin King <colin.k...@canonical.com>:
> >   
> >> From: Colin Ian King <colin.k...@canonical.com>
> >>
> >> In function stop there is a check to see if state->demod is a stopped
> >> value of 0xff, however, later on, array demod_in_use is indexed with
> >> this value causing an out-of-bounds write error.  Avoid this by only
> >> writing to array demod_in_use if state->demod is not set to the stopped
> >> sentinal value for this specific corner case.  Also, replace the magic
> >> value 0xff with DEMOD_STOPPED to make code more readable.
> >>
> >> Detected by CoverityScan, CID#1468550 ("Out-of-bounds write")
> >>
> >> Fixes: daeeb1319e6f ("media: ddbridge: initial support for MCI-based 
> >> MaxSX8 cards")
> >> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
> >> ---
> >>  drivers/media/pci/ddbridge/ddbridge-mci.c | 11 +++
> >>  1 file changed, 7 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
> >> b/drivers/media/pci/ddbridge/ddbridge-mci.c
> >> index a85ff3e6b919..1f5ed53c8d35 100644
> >> --- a/drivers/media/pci/ddbridge/ddbridge-mci.c
> >> +++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
> >> @@ -20,6 +20,8 @@
> >>  #include "ddbridge-io.h"
> >>  #include "ddbridge-mci.h"
> >>  
> >> +#define DEMOD_STOPPED (0xff)
> >> +
> >>  static LIST_HEAD(mci_list);
> >>  
> >>  static const u32 MCLK = (155000 / 12);
> >> @@ -193,7 +195,7 @@ static int stop(struct dvb_frontend *fe)
> >>u32 input = state->tuner;
> >>  
> >>memset(, 0, sizeof(cmd));
> >> -  if (state->demod != 0xff) {
> >> +  if (state->demod != DEMOD_STOPPED) {
> >>cmd.command = MCI_CMD_STOP;
> >>cmd.demod = state->demod;
> >>mci_cmd(state, , NULL);
> >> @@ -209,10 +211,11 @@ static int stop(struct dvb_frontend *fe)
> >>state->base->tuner_use_count[input]--;
> >>if (!state->base->tuner_use_count[input])
> >>mci_set_tuner(fe, input, 0);
> >> -  state->base->demod_in_use[state->demod] = 0;
> >> +  if (state->demod != DEMOD_STOPPED)
> >> +  state->base->demod_in_use[state->demod] = 0;
> >>state->base->used_ldpc_bitrate[state->nr] = 0;
> >> -  state->demod = 0xff;
> >> -  state->base->assigned_demod[state->nr] = 0xff;
> >> +  state->demod = DEMOD_STOPPED;
> >> +  state->base->assigned_demod[state->nr] = DEMOD_STOPPED;
> >>state->base->iq_mode = 0;
> >>mutex_unlock(>base->tuner_lock);
> >>state->started = 0;  
> > 
> > Thanks for the patch, or - better - pointing this out. While it's
> > unlikely this will ever be an issue, I'm fine with changing the code
> > like that, but I'd prefer to change it a bit differently (ie.
> > DEMOD_STOPPED should be DEMOD_UNUSED, and I'd add defines for max.
> > tuners and use/compare against them).  
> 
> Sounds like a good idea.
> 
> > 
> > I'll send out a different patch that will cover the potential
> > coverityscan problem throughout the end of the week.  
> 
> Great. Thanks!

JFYI, patch sent as part of a few other fixes and up at linux-media
patchwork:

https://patchwork.linuxtv.org/patch/49403/

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH 4/4] [media] ddbridge: conditionally enable fast TS for stv0910-equipped bridges

2018-05-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

CineS2 V7(A) and Octopus CI S2 Pro/Advanced cards support faster TS speeds
on the card's contained stv0910 demodulator when their FPGA was updated
with a recent (>= 1.7, version number applies to all mentioned cards)
vendor firmware. Enable this faster TS speed on card port 0 (contained
demod) and parallel stv0910 connections when the card firmware is at least
1.7 or later.

Note: The mentioned cards and their demods are handled via the STV0910_PR
and STV0910_P tuner types. DuoFlex modules with such demodulators are
handled via the STV0910 (without suffix) types where such TS speed
increase doesn't technically make sense.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
Tested-by: Richard Scobie <rasco...@slingshot.co.nz>
Tested-by: Helmut Auer <p...@helmutauer.de>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 34 +-
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 6c2341642017..d5b0d1eaf3ad 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1191,7 +1191,7 @@ static const struct lnbh25_config lnbh25_cfg = {
.data2_config = LNBH25_TEN
 };
 
-static int demod_attach_stv0910(struct ddb_input *input, int type)
+static int demod_attach_stv0910(struct ddb_input *input, int type, int tsfast)
 {
struct i2c_adapter *i2c = >port->i2c->adap;
struct ddb_dvb *dvb = >port->dvb[input->nr & 1];
@@ -1204,6 +1204,12 @@ static int demod_attach_stv0910(struct ddb_input *input, 
int type)
 
if (type)
cfg.parallel = 2;
+
+   if (tsfast) {
+   dev_info(dev, "Enabling stv0910 higher speed TS\n");
+   cfg.tsspeed = 0x10;
+   }
+
dvb->fe = dvb_attach(stv0910_attach, i2c, , (input->nr & 1));
if (!dvb->fe) {
cfg.adr = 0x6c;
@@ -1439,7 +1445,25 @@ static int dvb_input_attach(struct ddb_input *input)
struct ddb_port *port = input->port;
struct dvb_adapter *adap = dvb->adap;
struct dvb_demux *dvbdemux = >demux;
-   int par = 0, osc24 = 0;
+   struct ddb_ids *devids = >port->dev->link[input->port->lnr].ids;
+   int par = 0, osc24 = 0, tsfast = 0;
+
+   /*
+* Determine if bridges with stv0910 demods can run with fast TS and
+* thus support high bandwidth transponders.
+* STV0910_PR and STV0910_P tuner types covers all relevant bridges,
+* namely the CineS2 V7(A) and the Octopus CI S2 Pro/Advanced. All
+* DuoFlex S2 V4(A) have type=DDB_TUNER_DVBS_STV0910 without any suffix
+* and are limited by the serial link to the bridge, thus won't work
+* in fast TS mode.
+*/
+   if (port->nr == 0 &&
+   (port->type == DDB_TUNER_DVBS_STV0910_PR ||
+port->type == DDB_TUNER_DVBS_STV0910_P)) {
+   /* fast TS on port 0 requires FPGA version >= 1.7 */
+   if ((devids->hwid & 0x00ff) >= 0x00010007)
+   tsfast = 1;
+   }
 
dvb->attached = 0x01;
 
@@ -1496,19 +1520,19 @@ static int dvb_input_attach(struct ddb_input *input)
goto err_tuner;
break;
case DDB_TUNER_DVBS_STV0910:
-   if (demod_attach_stv0910(input, 0) < 0)
+   if (demod_attach_stv0910(input, 0, tsfast) < 0)
goto err_detach;
if (tuner_attach_stv6111(input, 0) < 0)
goto err_tuner;
break;
case DDB_TUNER_DVBS_STV0910_PR:
-   if (demod_attach_stv0910(input, 1) < 0)
+   if (demod_attach_stv0910(input, 1, tsfast) < 0)
goto err_detach;
if (tuner_attach_stv6111(input, 1) < 0)
goto err_tuner;
break;
case DDB_TUNER_DVBS_STV0910_P:
-   if (demod_attach_stv0910(input, 0) < 0)
+   if (demod_attach_stv0910(input, 0, tsfast) < 0)
goto err_detach;
if (tuner_attach_stv6111(input, 1) < 0)
goto err_tuner;
-- 
2.16.1



[PATCH 1/4] [media] ddbridge/mci: protect against out-of-bounds array access in stop()

2018-05-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

In stop(), an (unlikely) out-of-bounds write error can occur when setting
the demod_in_use element indexed by state->demod to zero, as state->demod
isn't checked for being in the range of the array size of demod_in_use, and
state->demod maybe carrying the magic 0xff (demod unused) value. Prevent
this by checking state->demod not exceeding the array size before setting
the element value. To make the code a bit easier to read, replace the magic
value and the number of array elements with defines, and use them at a few
more places.

Detected by CoverityScan, CID#1468550 ("Out-of-bounds write")

Thanks to Colin for reporting the problem and providing an initial patch.

Fixes: daeeb1319e6f ("media: ddbridge: initial support for MCI-based MaxSX8 
cards")
Reported-by: Colin Ian King <colin.k...@canonical.com>
Cc: Ralph Metzler <r...@metzlerbros.de>
Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-mci.c | 21 +++--
 drivers/media/pci/ddbridge/ddbridge-mci.h |  4 
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index a85ff3e6b919..8d9592e75ad5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -38,10 +38,10 @@ struct mci_base {
struct mutex mci_lock; /* concurrent MCI access lock */
int  count;
 
-   u8   tuner_use_count[4];
-   u8   assigned_demod[8];
-   u32  used_ldpc_bitrate[8];
-   u8   demod_in_use[8];
+   u8   tuner_use_count[MCI_TUNER_MAX];
+   u8   assigned_demod[MCI_DEMOD_MAX];
+   u32  used_ldpc_bitrate[MCI_DEMOD_MAX];
+   u8   demod_in_use[MCI_DEMOD_MAX];
u32  iq_mode;
 };
 
@@ -193,7 +193,7 @@ static int stop(struct dvb_frontend *fe)
u32 input = state->tuner;
 
memset(, 0, sizeof(cmd));
-   if (state->demod != 0xff) {
+   if (state->demod != DEMOD_UNUSED) {
cmd.command = MCI_CMD_STOP;
cmd.demod = state->demod;
mci_cmd(state, , NULL);
@@ -209,10 +209,11 @@ static int stop(struct dvb_frontend *fe)
state->base->tuner_use_count[input]--;
if (!state->base->tuner_use_count[input])
mci_set_tuner(fe, input, 0);
-   state->base->demod_in_use[state->demod] = 0;
+   if (state->demod < MCI_DEMOD_MAX)
+   state->base->demod_in_use[state->demod] = 0;
state->base->used_ldpc_bitrate[state->nr] = 0;
-   state->demod = 0xff;
-   state->base->assigned_demod[state->nr] = 0xff;
+   state->demod = DEMOD_UNUSED;
+   state->base->assigned_demod[state->nr] = DEMOD_UNUSED;
state->base->iq_mode = 0;
mutex_unlock(>base->tuner_lock);
state->started = 0;
@@ -250,7 +251,7 @@ static int start(struct dvb_frontend *fe, u32 flags, u32 
modmask, u32 ts_config)
stat = -EBUSY;
goto unlock;
}
-   for (i = 0; i < 8; i++) {
+   for (i = 0; i < MCI_DEMOD_MAX; i++) {
used_ldpc_bitrate += state->base->used_ldpc_bitrate[i];
if (state->base->demod_in_use[i])
used_demods++;
@@ -342,7 +343,7 @@ static int start_iq(struct dvb_frontend *fe, u32 ts_config)
stat = -EBUSY;
goto unlock;
}
-   for (i = 0; i < 8; i++)
+   for (i = 0; i < MCI_DEMOD_MAX; i++)
if (state->base->demod_in_use[i])
used_demods++;
if (used_demods > 0) {
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index c4193c5ee095..453dcb9f8208 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -19,6 +19,10 @@
 #ifndef _DDBRIDGE_MCI_H_
 #define _DDBRIDGE_MCI_H_
 
+#define MCI_DEMOD_MAX   8
+#define MCI_TUNER_MAX   4
+#define DEMOD_UNUSED(0xFF)
+
 #define MCI_CONTROL (0x500)
 #define MCI_COMMAND (0x600)
 #define MCI_RESULT  (0x680)
-- 
2.16.1



[PATCH 3/4] [media] dvb-frontends/stv0910: make TS speed configurable

2018-05-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Add a tsspeed config option to struct stv0910_cfg which can be used by
users of the driver to set the (parallel) TS speed (higher speeds enable
support for higher bitrate transponders). If tsspeed isn't set in the
config, it'll default to a sane value.

This commit also updates the two consumers of the stv0910 driver (ngene
and ddbridge) to have a default tsspeed in their stv0910_cfg templates.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
Tested-by: Richard Scobie <rasco...@slingshot.co.nz>
Tested-by: Helmut Auer <p...@helmutauer.de>
---
 drivers/media/dvb-frontends/stv0910.c  | 5 ++---
 drivers/media/dvb-frontends/stv0910.h  | 1 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 1 +
 drivers/media/pci/ngene/ngene-cards.c  | 1 +
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 7e9b016b3b28..41444fa1c0bb 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1200,7 +1200,6 @@ static int probe(struct stv *state)
write_reg(state, RSTV0910_P1_TSCFGM, 0xC0); /* Manual speed */
write_reg(state, RSTV0910_P1_TSCFGL, 0x20);
 
-   /* Speed = 67.5 MHz */
write_reg(state, RSTV0910_P1_TSSPEED, state->tsspeed);
 
write_reg(state, RSTV0910_P2_TSCFGH, state->tscfgh | 0x01);
@@ -1208,7 +1207,6 @@ static int probe(struct stv *state)
write_reg(state, RSTV0910_P2_TSCFGM, 0xC0); /* Manual speed */
write_reg(state, RSTV0910_P2_TSCFGL, 0x20);
 
-   /* Speed = 67.5 MHz */
write_reg(state, RSTV0910_P2_TSSPEED, state->tsspeed);
 
/* Reset stream merger */
@@ -1790,7 +1788,8 @@ struct dvb_frontend *stv0910_attach(struct i2c_adapter 
*i2c,
state->tscfgh = 0x20 | (cfg->parallel ? 0 : 0x40);
state->tsgeneral = (cfg->parallel == 2) ? 0x02 : 0x00;
state->i2crpt = 0x0A | ((cfg->rptlvl & 0x07) << 4);
-   state->tsspeed = 0x28;
+   /* use safe tsspeed value if unspecified through stv0910_cfg */
+   state->tsspeed = (cfg->tsspeed ? cfg->tsspeed : 0x28);
state->nr = nr;
state->regoff = state->nr ? 0 : 0x200;
state->search_range = 1600;
diff --git a/drivers/media/dvb-frontends/stv0910.h 
b/drivers/media/dvb-frontends/stv0910.h
index fccd8d9b665f..f37171b7a2de 100644
--- a/drivers/media/dvb-frontends/stv0910.h
+++ b/drivers/media/dvb-frontends/stv0910.h
@@ -10,6 +10,7 @@ struct stv0910_cfg {
u8  parallel;
u8  rptlvl;
u8  single;
+   u8  tsspeed;
 };
 
 #if IS_REACHABLE(CONFIG_DVB_STV0910)
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 377269c64449..6c2341642017 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1183,6 +1183,7 @@ static const struct stv0910_cfg stv0910_p = {
.parallel = 1,
.rptlvl   = 4,
.clk  = 3000,
+   .tsspeed  = 0x28,
 };
 
 static const struct lnbh25_config lnbh25_cfg = {
diff --git a/drivers/media/pci/ngene/ngene-cards.c 
b/drivers/media/pci/ngene/ngene-cards.c
index 7738565193d6..7a106bc11a2b 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -327,6 +327,7 @@ static struct stv0910_cfg stv0910_p = {
.parallel = 1,
.rptlvl   = 4,
.clk  = 3000,
+   .tsspeed  = 0x28,
 };
 
 static struct lnbh25_config lnbh25_cfg = {
-- 
2.16.1



[PATCH 2/4] [media] ddbridge/mci: add identifiers to function definition arguments

2018-05-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Fixes two checkpatch warnings

  WARNING: function definition argument 'xxx' should also have an identifier 
name

in the ddb_mci_attach() prototype definition. checkpatch keeps complaining
on the "int (**fn_set_input)" as it seems to have issues with the
ptr-to-ptr, though this probably needs fixing in checkpatch.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-mci.c | 2 +-
 drivers/media/pci/ddbridge/ddbridge-mci.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
index 8d9592e75ad5..4ac634fc96e4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.c
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -500,7 +500,7 @@ static int probe(struct mci *state)
 struct dvb_frontend
 *ddb_mci_attach(struct ddb_input *input,
int mci_type, int nr,
-   int (**fn_set_input)(struct dvb_frontend *, int))
+   int (**fn_set_input)(struct dvb_frontend *fe, int input))
 {
struct ddb_port *port = input->port;
struct ddb *dev = port->dev;
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.h 
b/drivers/media/pci/ddbridge/ddbridge-mci.h
index 453dcb9f8208..209cc2b92dff 100644
--- a/drivers/media/pci/ddbridge/ddbridge-mci.h
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.h
@@ -151,6 +151,6 @@ struct mci_result {
 struct dvb_frontend
 *ddb_mci_attach(struct ddb_input *input,
int mci_type, int nr,
-   int (**fn_set_input)(struct dvb_frontend *, int));
+   int (**fn_set_input)(struct dvb_frontend *fe, int input));
 
 #endif /* _DDBRIDGE_MCI_H_ */
-- 
2.16.1



[PATCH 0/4] ddbridge-0.9.33 fixes and improvements

2018-05-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Four post-ddbridge-0.9.33 patches fixing and improving a few things:

Patch 1 adds protection into the new ddbridge-mci code against an
out-of-bounds array write access as reported by CoverityScan and brought
to attention by Colin Ian King.

Patch 2 adds missing function argument identifiers to ddb_mci_attach() to
silence checkpatch. It still complains about the **fn_set_input which IS
the identifier but doesn't seem to be caught by checkpatch properly.

Patches 3 and 4 enable the higher speed TS mode on stv0910-equipped cards
and thus enables for higher bitrate transponders when the detected card
firmware permits this. This is basically what was removed in the initial
ddbridge-0.9.33 patch series but enhanced to be only enabled when the
FPGA firmware permits this.

Please merge, this should go in alongside the already merged ddbridge
0.9.33 patches. Thanks.

Daniel Scheller (4):
  [media] ddbridge/mci: protect against out-of-bounds array access in
stop()
  [media] ddbridge/mci: add identifiers to function definition arguments
  [media] dvb-frontends/stv0910: make TS speed configurable
  [media] ddbridge: conditionally enable fast TS for stv0910-equipped
bridges

 drivers/media/dvb-frontends/stv0910.c  |  5 ++---
 drivers/media/dvb-frontends/stv0910.h  |  1 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 35 +-
 drivers/media/pci/ddbridge/ddbridge-mci.c  | 23 ++--
 drivers/media/pci/ddbridge/ddbridge-mci.h  |  6 -
 drivers/media/pci/ngene/ngene-cards.c  |  1 +
 6 files changed, 51 insertions(+), 20 deletions(-)

-- 
2.16.1



Re: [PATCH][media-next] media: ddbridge: avoid out-of-bounds write on array demod_in_use

2018-05-08 Thread Daniel Scheller
Hi Colin,

Am Tue,  8 May 2018 00:08:42 +0100
schrieb Colin King <colin.k...@canonical.com>:

> From: Colin Ian King <colin.k...@canonical.com>
> 
> In function stop there is a check to see if state->demod is a stopped
> value of 0xff, however, later on, array demod_in_use is indexed with
> this value causing an out-of-bounds write error.  Avoid this by only
> writing to array demod_in_use if state->demod is not set to the stopped
> sentinal value for this specific corner case.  Also, replace the magic
> value 0xff with DEMOD_STOPPED to make code more readable.
> 
> Detected by CoverityScan, CID#1468550 ("Out-of-bounds write")
> 
> Fixes: daeeb1319e6f ("media: ddbridge: initial support for MCI-based MaxSX8 
> cards")
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
> ---
>  drivers/media/pci/ddbridge/ddbridge-mci.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
> b/drivers/media/pci/ddbridge/ddbridge-mci.c
> index a85ff3e6b919..1f5ed53c8d35 100644
> --- a/drivers/media/pci/ddbridge/ddbridge-mci.c
> +++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
> @@ -20,6 +20,8 @@
>  #include "ddbridge-io.h"
>  #include "ddbridge-mci.h"
>  
> +#define DEMOD_STOPPED(0xff)
> +
>  static LIST_HEAD(mci_list);
>  
>  static const u32 MCLK = (155000 / 12);
> @@ -193,7 +195,7 @@ static int stop(struct dvb_frontend *fe)
>   u32 input = state->tuner;
>  
>   memset(, 0, sizeof(cmd));
> - if (state->demod != 0xff) {
> + if (state->demod != DEMOD_STOPPED) {
>   cmd.command = MCI_CMD_STOP;
>   cmd.demod = state->demod;
>   mci_cmd(state, , NULL);
> @@ -209,10 +211,11 @@ static int stop(struct dvb_frontend *fe)
>   state->base->tuner_use_count[input]--;
>   if (!state->base->tuner_use_count[input])
>   mci_set_tuner(fe, input, 0);
> - state->base->demod_in_use[state->demod] = 0;
> + if (state->demod != DEMOD_STOPPED)
> + state->base->demod_in_use[state->demod] = 0;
>   state->base->used_ldpc_bitrate[state->nr] = 0;
> - state->demod = 0xff;
> - state->base->assigned_demod[state->nr] = 0xff;
> + state->demod = DEMOD_STOPPED;
> + state->base->assigned_demod[state->nr] = DEMOD_STOPPED;
>   state->base->iq_mode = 0;
>   mutex_unlock(>base->tuner_lock);
>   state->started = 0;

Thanks for the patch, or - better - pointing this out. While it's
unlikely this will ever be an issue, I'm fine with changing the code
like that, but I'd prefer to change it a bit differently (ie.
DEMOD_STOPPED should be DEMOD_UNUSED, and I'd add defines for max.
tuners and use/compare against them).

I'll send out a different patch that will cover the potential
coverityscan problem throughout the end of the week.

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


Re: [PATCH v3 1/3] [media] dvb_frontend: add S2X and misc. other enums

2018-05-07 Thread Daniel Scheller
Am Fri, 4 May 2018 12:51:02 -0300
schrieb Mauro Carvalho Chehab <mchehab+sams...@kernel.org>:

> Em Tue, 13 Mar 2018 23:18:03 +0100
> Daniel Scheller <d.scheller@gmail.com> escreveu:
> 
> > From: Daniel Scheller <d.schel...@gmx.net>
> > 
> > Additional enums:
> >  * FEC ratios 1/4 and 1/3
> >  * 64/128/256-APSK modulations (DVB-S2X)
> >  * 15%, 10% and 5% rolloff factors (DVB-S2X)
> >  * 64K transmission mode (DVB-T2)
> > 
> > Add these enums to the frontend.h docs exceptions aswell (uapi docs are
> > updated separately).
> > 
> > Also, bump the DVB API version to 5.12 to make userspace aware of these
> > new enums.  
> 
> Series look good, except for one detail: how userspace would know if
> a device supports S2(X) or not?

I don't think userspace (applications) actually do really need to
know since there's nothing additionally applications have to set up wrt
dealing with S2X. They simply set frequency, symbolrate and
optionally SYS_DVBS2 (and I have a feeling they don't even have to do
this since drivers or demods, even, will care about S or S2, or S2X
themselves). In fact, all that these patches do (and what is
necessary, and what S2X is about) is to add the enum values which demod
drivers then can report via the get_frontend IOCTL.

Of course we can add a SYS_DVBS2X and put that to the caps fe_ops of
S2X supporting drivers, but in the end we would only change all

  if (SYS_DVBS2...) {}

to

  if (SYS_DVBS2 || SYS_DVBS2X...) {}

as there are no new fancy properties for S2X but only more rolloffs and
modulation types. Adding a FE_CAN_DVBS2X won't work at this time since
there are no more bits left on this caps value.

So (since you marked the series as "Changes requested"), please maybe
reconsider, and I believe a SYS_DVBS2X would add more clutter than it'd
help. Or: Please advise.

Note: If you prefer to overhaul all the caps things (as we had a quick
chat about on IRC), I prefer to leave this task up to someone else due
to lack of time, and someone else even might even better know what's
necessary.

> 
> > 
> > Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
> > ---
> > v2 to v3:
> > - All new enum patches squashed into one commit
> > - DVB API bump to 5.12
> > 
> > Please take note of some additional things in the cover letter.
> > 
> >  Documentation/media/frontend.h.rst.exceptions |  9 +
> >  drivers/media/dvb-core/dvb_frontend.c |  9 +
> >  include/uapi/linux/dvb/frontend.h | 29 
> > ++-
> >  include/uapi/linux/dvb/version.h  |  2 +-
> >  4 files changed, 43 insertions(+), 6 deletions(-)
> > 
> > diff --git a/Documentation/media/frontend.h.rst.exceptions 
> > b/Documentation/media/frontend.h.rst.exceptions
> > index f7c4df620a52..c1643ce93426 100644
> > --- a/Documentation/media/frontend.h.rst.exceptions
> > +++ b/Documentation/media/frontend.h.rst.exceptions
> > @@ -84,6 +84,9 @@ ignore symbol APSK_16
> >  ignore symbol APSK_32
> >  ignore symbol DQPSK
> >  ignore symbol QAM_4_NR
> > +ignore symbol APSK_64
> > +ignore symbol APSK_128
> > +ignore symbol APSK_256
> >  
> >  ignore symbol SEC_VOLTAGE_13
> >  ignore symbol SEC_VOLTAGE_18
> > @@ -117,6 +120,8 @@ ignore symbol FEC_AUTO
> >  ignore symbol FEC_3_5
> >  ignore symbol FEC_9_10
> >  ignore symbol FEC_2_5
> > +ignore symbol FEC_1_4
> > +ignore symbol FEC_1_3
> >  
> >  ignore symbol TRANSMISSION_MODE_AUTO
> >  ignore symbol TRANSMISSION_MODE_1K
> > @@ -129,6 +134,7 @@ ignore symbol TRANSMISSION_MODE_C1
> >  ignore symbol TRANSMISSION_MODE_C3780
> >  ignore symbol TRANSMISSION_MODE_2K
> >  ignore symbol TRANSMISSION_MODE_8K
> > +ignore symbol TRANSMISSION_MODE_64K
> >  
> >  ignore symbol GUARD_INTERVAL_AUTO
> >  ignore symbol GUARD_INTERVAL_1_128
> > @@ -161,6 +167,9 @@ ignore symbol ROLLOFF_35
> >  ignore symbol ROLLOFF_20
> >  ignore symbol ROLLOFF_25
> >  ignore symbol ROLLOFF_AUTO
> > +ignore symbol ROLLOFF_15
> > +ignore symbol ROLLOFF_10
> > +ignore symbol ROLLOFF_5
> >  
> >  ignore symbol INVERSION_ON
> >  ignore symbol INVERSION_OFF
> > diff --git a/drivers/media/dvb-core/dvb_frontend.c 
> > b/drivers/media/dvb-core/dvb_frontend.c
> > index a7ed16e0841d..52c76e32f864 100644
> > --- a/drivers/media/dvb-core/dvb_frontend.c
> > +++ b/drivers/media/dvb-core/dvb_frontend.c
> > @@ -2183,6 +2183,15 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
> > break;
> > case SYS_DVBS2:
> > switch (c-&g

Re: [PATCH] media: mxl5xx: fix get_algo()'s return type

2018-04-24 Thread Daniel Scheller
Am Tue, 24 Apr 2018 15:19:31 +0200
schrieb Luc Van Oostenryck <luc.vanoostenr...@gmail.com>:

> The method dvb_frontend_ops::get_frontend_algo() is defined as
> returning an 'enum dvbfe_algo', but the implementation in this
> driver returns an 'int'.
> 
> Fix this by returning 'enum dvbfe_algo' in this driver too.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenr...@gmail.com>
> ---
>  drivers/media/dvb-frontends/mxl5xx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/dvb-frontends/mxl5xx.c 
> b/drivers/media/dvb-frontends/mxl5xx.c
> index 483ee7d61..274d8fca0 100644
> --- a/drivers/media/dvb-frontends/mxl5xx.c
> +++ b/drivers/media/dvb-frontends/mxl5xx.c
> @@ -375,7 +375,7 @@ static void release(struct dvb_frontend *fe)
>   kfree(state);
>  }
>  
> -static int get_algo(struct dvb_frontend *fe)
> +static enum dvbfe_algo get_algo(struct dvb_frontend *fe)
>  {
>   return DVBFE_ALGO_HW;
>  }

Acked-by: Daniel Scheller <d.schel...@gmx.net>

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


Re: [PATCH] media: stv0910: fix get_algo()'s return type

2018-04-24 Thread Daniel Scheller
Am Tue, 24 Apr 2018 15:19:38 +0200
schrieb Luc Van Oostenryck <luc.vanoostenr...@gmail.com>:

> The method dvb_frontend_ops::get_frontend_algo() is defined as
> returning an 'enum dvbfe_algo', but the implementation in this
> driver returns an 'int'.
> 
> Fix this by returning 'enum dvbfe_algo' in this driver too.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenr...@gmail.com>
> ---
>  drivers/media/dvb-frontends/stv0910.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/dvb-frontends/stv0910.c 
> b/drivers/media/dvb-frontends/stv0910.c
> index 52355c14f..50234d311 100644
> --- a/drivers/media/dvb-frontends/stv0910.c
> +++ b/drivers/media/dvb-frontends/stv0910.c
> @@ -1633,7 +1633,7 @@ static int tune(struct dvb_frontend *fe, bool re_tune,
>   return 0;
>  }
>  
> -static int get_algo(struct dvb_frontend *fe)
> +static enum dvbfe_algo get_algo(struct dvb_frontend *fe)
>  {
>   return DVBFE_ALGO_HW;
>  }

Acked-by: Daniel Scheller <d.schel...@gmx.net>

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH 2/2] [media] ngene: fix ci_tsfix modparam description typo

2018-04-22 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

s/shifs/shifts/

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ngene/ngene-dvb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ngene/ngene-dvb.c 
b/drivers/media/pci/ngene/ngene-dvb.c
index fee89b9ed9c1..5147e83397a1 100644
--- a/drivers/media/pci/ngene/ngene-dvb.c
+++ b/drivers/media/pci/ngene/ngene-dvb.c
@@ -40,7 +40,7 @@
 
 static int ci_tsfix = 1;
 module_param(ci_tsfix, int, 0444);
-MODULE_PARM_DESC(ci_tsfix, "Detect and fix TS buffer offset shifs in 
conjunction with CI expansions (default: 1/enabled)");
+MODULE_PARM_DESC(ci_tsfix, "Detect and fix TS buffer offset shifts in 
conjunction with CI expansions (default: 1/enabled)");
 
 //
 /* COMMAND API interface /
-- 
2.16.1



[PATCH 1/2] [media] ngene: cleanup superfluous I2C adapter evaluation

2018-04-22 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Commit ee93340e98bc ("media: ngene: deduplicate I2C adapter evaluation")
added a helper to evaluate the I2C adapter to be used for demod/tuner
attachment based on the given ngene_channel, and that helper is used in
many attach functions to initialise the i2c_adapter variable. However,
for some reason in tuner_attach_stv6110() and demod_attach_stv0900(), the
adapter evaluation wasn't removed as in all other functions. Fix (or
finalize, even) the helper use by cleaning up the superfluous I2C adapter
evaluation leftover in these two functions.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ngene/ngene-cards.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-cards.c 
b/drivers/media/pci/ngene/ngene-cards.c
index 65fc8f23ad86..caa5976055c4 100644
--- a/drivers/media/pci/ngene/ngene-cards.c
+++ b/drivers/media/pci/ngene/ngene-cards.c
@@ -137,11 +137,6 @@ static int tuner_attach_stv6110(struct ngene_channel *chan)
chan->dev->card_info->tuner_config[chan->number];
const struct stv6110x_devctl *ctl;
 
-   if (chan->number < 2)
-   i2c = >dev->channel[0].i2c_adapter;
-   else
-   i2c = >dev->channel[1].i2c_adapter;
-
ctl = dvb_attach(stv6110x_attach, chan->fe, tunerconf, i2c);
if (ctl == NULL) {
dev_err(pdev, "No STV6110X found!\n");
@@ -304,14 +299,6 @@ static int demod_attach_stv0900(struct ngene_channel *chan)
struct stv090x_config *feconf = (struct stv090x_config *)
chan->dev->card_info->fe_config[chan->number];
 
-   /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
-   /* Note: Both adapters share the same i2c bus, but the demod */
-   /*   driver requires that each demod has its own i2c adapter */
-   if (chan->number < 2)
-   i2c = >dev->channel[0].i2c_adapter;
-   else
-   i2c = >dev->channel[1].i2c_adapter;
-
chan->fe = dvb_attach(stv090x_attach, feconf, i2c,
(chan->number & 1) == 0 ? STV090x_DEMODULATOR_0
: STV090x_DEMODULATOR_1);
-- 
2.16.1



Re: [PATCH v2 18/19] media: si470x: allow build both USB and I2C at the same time

2018-04-18 Thread Daniel Scheller
Am Wed, 18 Apr 2018 15:53:09 -0300
schrieb Mauro Carvalho Chehab <mche...@s-opensource.com>:

> Em Wed, 18 Apr 2018 19:07:40 +0200
> Daniel Scheller <d.scheller@gmail.com> escreveu:
> 
> > Am Fri, 6 Apr 2018 13:46:03 -0300
> > schrieb Mauro Carvalho Chehab <mche...@s-opensource.com>:
> >   
> > > Em Sat, 7 Apr 2018 00:21:07 +0800
> > > kbuild test robot <l...@intel.com> escreveu:
> > > 
> > > > Hi Mauro,
> > > > 
> > > > I love your patch! Yet something to improve:
> > > > [...]
> > > 
> > > Fixed patch enclosed.
> > > 
> > > Thanks,
> > > Mauro
> > > 
> > > [PATCH] media: si470x: allow build both USB and I2C at the same
> > > time
> > > 
> > > Currently, either USB or I2C is built. Change it to allow
> > > having both enabled at the same time.
> > > 
> > > The main reason is that COMPILE_TEST all[yes/mod]builds will
> > > now contain all drivers under drivers/media.
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab
> > > <mche...@s-opensource.com>
> > 
> > FWIW, this patch (which seemingly is commit
> > 58757984ca3c73284a45dd53ac66f1414057cd09 in media_tree.git) seems
> > to break media_build in a way that on my systems only 20 drivers
> > and modules are built now, while it should be in the 650+ modules
> > range. Hans' automated daily testbuilds suffer from the same issue,
> > looking at todays daily build logs (Wednesday.tar.bz2). I
> > personally build against Kernel 4.16.2 on Gentoo.
> > 
> > This specific commit/patch was found using
> > 
> >   # git bisect good v4.17-rc1
> >   # git bisect bad media_tree/master
> > 
> > And, "git revert 58767984..." makes all drivers being built again by
> > media_build.
> > 
> > Not sure if there's something other for which this patch acts as the
> > trigger of if this needs adaption in media_build, though I thought
> > reporting this doesn't hurt.
> > 
> > Best regards,
> > Daniel Scheller  
> 
> Please try this:
> 
> diff --git a/drivers/media/radio/si470x/Makefile
> b/drivers/media/radio/si470x/Makefile index
> 563500823e04..682b3146397e 100644 ---
> a/drivers/media/radio/si470x/Makefile +++
> b/drivers/media/radio/si470x/Makefile @@ -2,6 +2,6 @@
>  # Makefile for radios with Silicon Labs Si470x FM Radio Receivers
>  #
>  
> -obj-$(CONFIG_RADIO_SI470X) := radio-si470x-common.o
> +obj-$(CONFIG_RADIO_SI470X) += radio-si470x-common.o
>  obj-$(CONFIG_USB_SI470X) += radio-si470x-usb.o
>  obj-$(CONFIG_I2C_SI470X) += radio-si470x-i2c.o

That (ontop of media_tree.git HEAD) fixes it, back to 656 modules.

Thanks!

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


Re: [PATCH v2 18/19] media: si470x: allow build both USB and I2C at the same time

2018-04-18 Thread Daniel Scheller
Am Fri, 6 Apr 2018 13:46:03 -0300
schrieb Mauro Carvalho Chehab <mche...@s-opensource.com>:

> Em Sat, 7 Apr 2018 00:21:07 +0800
> kbuild test robot <l...@intel.com> escreveu:
> 
> > Hi Mauro,
> > 
> > I love your patch! Yet something to improve:
> > [...]
> 
> Fixed patch enclosed.
> 
> Thanks,
> Mauro
> 
> [PATCH] media: si470x: allow build both USB and I2C at the same time
> 
> Currently, either USB or I2C is built. Change it to allow
> having both enabled at the same time.
> 
> The main reason is that COMPILE_TEST all[yes/mod]builds will
> now contain all drivers under drivers/media.
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>

FWIW, this patch (which seemingly is commit
58757984ca3c73284a45dd53ac66f1414057cd09 in media_tree.git) seems to break 
media_build in a way that on my systems only 20 drivers and modules are built 
now, while it should be in the 650+ modules range. Hans' automated daily 
testbuilds suffer from the same issue, looking at todays daily build logs 
(Wednesday.tar.bz2). I personally build against Kernel 4.16.2 on Gentoo.

This specific commit/patch was found using

  # git bisect good v4.17-rc1
  # git bisect bad media_tree/master

And, "git revert 58767984..." makes all drivers being built again by
media_build.

Not sure if there's something other for which this patch acts as the
trigger of if this needs adaption in media_build, though I thought
reporting this doesn't hurt.

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH] [media] ddbridge: don't uselessly check for dma in start/stop functions

2018-04-16 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The check for a valid ptr in ddb_io->dma isn't really necessary since only
devices that do data transport using DMA are supported by the driver, and
all previous initialisation code (through input_init(), output_init() and
dma_init(), has_dma is always true as it's set in ddb_probe() during
driver load) guarantees the ptr is set.

As a side effect, this silences these sparse warnings (albeit them being
false positives as ddb_io->dma won't change in these functions so the
condition always equals to the same result):

drivers/media/pci/ddbridge/ddbridge-core.c:495:9: warning: context 
imbalance in 'ddb_output_start' - different lock contexts for basic block
drivers/media/pci/ddbridge/ddbridge-core.c:510:9: warning: context 
imbalance in 'ddb_output_stop' - different lock contexts for basic block
drivers/media/pci/ddbridge/ddbridge-core.c:525:9: warning: context 
imbalance in 'ddb_input_stop' - different lock contexts for basic block
drivers/media/pci/ddbridge/ddbridge-core.c:560:9: warning: context 
imbalance in 'ddb_input_start' - different lock contexts for basic block

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
Superseds https://patchwork.linuxtv.org/patch/48593/

 drivers/media/pci/ddbridge/ddbridge-core.c | 85 --
 1 file changed, 35 insertions(+), 50 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 90687eff5909..c90f2933df8d 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -410,13 +410,11 @@ static void ddb_output_start(struct ddb_output *output)
struct ddb *dev = output->port->dev;
u32 con = 0x11c, con2 = 0;
 
-   if (output->dma) {
-   spin_lock_irq(>dma->lock);
-   output->dma->cbuf = 0;
-   output->dma->coff = 0;
-   output->dma->stat = 0;
-   ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma));
-   }
+   spin_lock_irq(>dma->lock);
+   output->dma->cbuf = 0;
+   output->dma->coff = 0;
+   output->dma->stat = 0;
+   ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma));
 
if (output->port->input[0]->port->class == DDB_PORT_LOOP)
con = (1UL << 13) | 0x14;
@@ -429,36 +427,29 @@ static void ddb_output_start(struct ddb_output *output)
ddbwritel(dev, con, TS_CONTROL(output));
ddbwritel(dev, con2, TS_CONTROL2(output));
 
-   if (output->dma) {
-   ddbwritel(dev, output->dma->bufval,
- DMA_BUFFER_SIZE(output->dma));
-   ddbwritel(dev, 0, DMA_BUFFER_ACK(output->dma));
-   ddbwritel(dev, 1, DMA_BASE_READ);
-   ddbwritel(dev, 7, DMA_BUFFER_CONTROL(output->dma));
-   }
+   ddbwritel(dev, output->dma->bufval,
+ DMA_BUFFER_SIZE(output->dma));
+   ddbwritel(dev, 0, DMA_BUFFER_ACK(output->dma));
+   ddbwritel(dev, 1, DMA_BASE_READ);
+   ddbwritel(dev, 7, DMA_BUFFER_CONTROL(output->dma));
 
ddbwritel(dev, con | 1, TS_CONTROL(output));
 
-   if (output->dma) {
-   output->dma->running = 1;
-   spin_unlock_irq(>dma->lock);
-   }
+   output->dma->running = 1;
+   spin_unlock_irq(>dma->lock);
 }
 
 static void ddb_output_stop(struct ddb_output *output)
 {
struct ddb *dev = output->port->dev;
 
-   if (output->dma)
-   spin_lock_irq(>dma->lock);
+   spin_lock_irq(>dma->lock);
 
ddbwritel(dev, 0, TS_CONTROL(output));
 
-   if (output->dma) {
-   ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma));
-   output->dma->running = 0;
-   spin_unlock_irq(>dma->lock);
-   }
+   ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma));
+   output->dma->running = 0;
+   spin_unlock_irq(>dma->lock);
 }
 
 static void ddb_input_stop(struct ddb_input *input)
@@ -466,45 +457,39 @@ static void ddb_input_stop(struct ddb_input *input)
struct ddb *dev = input->port->dev;
u32 tag = DDB_LINK_TAG(input->port->lnr);
 
-   if (input->dma)
-   spin_lock_irq(>dma->lock);
+   spin_lock_irq(>dma->lock);
+
ddbwritel(dev, 0, tag | TS_CONTROL(input));
-   if (input->dma) {
-   ddbwritel(dev, 0, DMA_BUFFER_CONTROL(input->dma));
-   input->dma->running = 0;
-   spin_unlock_irq(>dma->lock);
-   }
+
+   ddbwritel(dev, 0, DMA_BUFFER_CONTROL(input->dma));
+   input->dma->running = 0;
+   spin_unlock_irq(>dma->lock);
 }
 
 static void ddb_input_start(struct ddb_input *input)
 {

Re: [PATCH] media: ddbridge: better handle optional spin locks at the code

2018-04-11 Thread Daniel Scheller
Am Wed, 11 Apr 2018 13:33:02 -0300
schrieb Mauro Carvalho Chehab <mche...@s-opensource.com>:

> Em Wed, 11 Apr 2018 18:03:15 +0200
> Daniel Scheller <d.scheller@gmail.com> escreveu:
> 
> > Am Wed, 11 Apr 2018 08:03:37 -0400
> > schrieb Mauro Carvalho Chehab <mche...@s-opensource.com>:
> >   
> > > Currently, ddbridge produces 4 warnings on sparse:
> > >   drivers/media/pci/ddbridge/ddbridge-core.c:495:9: warning: context 
> > > imbalance in 'ddb_output_start' - different lock contexts for basic block
> > >   drivers/media/pci/ddbridge/ddbridge-core.c:510:9: warning: context 
> > > imbalance in 'ddb_output_stop' - different lock contexts for basic block
> > >   drivers/media/pci/ddbridge/ddbridge-core.c:525:9: warning: context 
> > > imbalance in 'ddb_input_stop' - different lock contexts for basic block
> > >   drivers/media/pci/ddbridge/ddbridge-core.c:560:9: warning: context 
> > > imbalance in 'ddb_input_start' - different lock contexts for basic block
> > > 
> > > Those are all false positives, but they result from the fact that
> > > there could potentially have some troubles at the locking schema,
> > > because the lock depends on a var (output->dma).
> > > 
> > > I discussed that in priv with Sparse author and with the current
> > > maintainer. Both believe that sparse is doing the right thing, and
> > > that the proper fix would be to change the code to make it clearer
> > > that, when spin_lock_irq() is called, spin_unlock_irq() will be
> > > also called.
> > > 
> > > That help not only static analyzers to better understand the code,
> > > but also humans that could need to take a look at the code.
> > > 
> > > It was also pointed that gcc would likely be smart enough to
> > > optimize the code and produce the same result. I double
> > > checked: indeed, the size of the driver didn't change after
> > > this patch.
> > > 
> > > Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
> > > ---
> > >  drivers/media/pci/ddbridge/ddbridge-core.c | 43 
> > > --
> > >  1 file changed, 29 insertions(+), 14 deletions(-)
> > > 
> > > diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
> > > b/drivers/media/pci/ddbridge/ddbridge-core.c
> > > index 4a2819d3e225..080e2189ca7f 100644
> > > --- a/drivers/media/pci/ddbridge/ddbridge-core.c
> > > +++ b/drivers/media/pci/ddbridge/ddbridge-core.c
> > > @@ -458,13 +458,12 @@ static void calc_con(struct ddb_output *output, u32 
> > > *con, u32 *con2, u32 flags)
> > >   *con2 = (nco << 16) | gap;
> > >  }
> > >  
> > > -static void ddb_output_start(struct ddb_output *output)
> > > +static void __ddb_output_start(struct ddb_output *output)
> > >  {
> > >   struct ddb *dev = output->port->dev;
> > >   u32 con = 0x11c, con2 = 0;
> > >  
> > >   if (output->dma) {
> > > - spin_lock_irq(>dma->lock);
> > >   output->dma->cbuf = 0;
> > >   output->dma->coff = 0;
> > >   output->dma->stat = 0;
> > > @@ -492,9 +491,18 @@ static void ddb_output_start(struct ddb_output 
> > > *output)
> > >  
> > >   ddbwritel(dev, con | 1, TS_CONTROL(output));
> > >  
> > > - if (output->dma) {
> > > + if (output->dma)
> > >   output->dma->running = 1;
> > > +}
> > > +
> > > +static void ddb_output_start(struct ddb_output *output)
> > > +{
> > > + if (output->dma) {
> > > + spin_lock_irq(>dma->lock);
> > > + __ddb_output_start(output);
> > >   spin_unlock_irq(>dma->lock);
> > > + } else {
> > > + __ddb_output_start(output);
> > >   }
> > >  }
> > 
> > This makes things look rather strange (at least to my eyes), especially
> > when simply trying to satisfy automated checkers, which in this case is
> > useless since both lock and unlock will always happen based on the same
> > condition ([input|output]->dma != NULL). Though I agree having the
> > locking inside a condition in it's current form isn't optimal, too, and
> > I also already thought about this in the past.
> > 
> > I'd rather try to fix this by checking for the dma ptrs at the
> > beginning of the four functions and immediately return if the ptr is
> > invalid. Thou

Re: [PATCH] media: ddbridge: better handle optional spin locks at the code

2018-04-11 Thread Daniel Scheller
Am Wed, 11 Apr 2018 08:03:37 -0400
schrieb Mauro Carvalho Chehab <mche...@s-opensource.com>:

> Currently, ddbridge produces 4 warnings on sparse:
>   drivers/media/pci/ddbridge/ddbridge-core.c:495:9: warning: context 
> imbalance in 'ddb_output_start' - different lock contexts for basic block
>   drivers/media/pci/ddbridge/ddbridge-core.c:510:9: warning: context 
> imbalance in 'ddb_output_stop' - different lock contexts for basic block
>   drivers/media/pci/ddbridge/ddbridge-core.c:525:9: warning: context 
> imbalance in 'ddb_input_stop' - different lock contexts for basic block
>   drivers/media/pci/ddbridge/ddbridge-core.c:560:9: warning: context 
> imbalance in 'ddb_input_start' - different lock contexts for basic block
> 
> Those are all false positives, but they result from the fact that
> there could potentially have some troubles at the locking schema,
> because the lock depends on a var (output->dma).
> 
> I discussed that in priv with Sparse author and with the current
> maintainer. Both believe that sparse is doing the right thing, and
> that the proper fix would be to change the code to make it clearer
> that, when spin_lock_irq() is called, spin_unlock_irq() will be
> also called.
> 
> That help not only static analyzers to better understand the code,
> but also humans that could need to take a look at the code.
> 
> It was also pointed that gcc would likely be smart enough to
> optimize the code and produce the same result. I double
> checked: indeed, the size of the driver didn't change after
> this patch.
> 
> Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
> ---
>  drivers/media/pci/ddbridge/ddbridge-core.c | 43 
> --
>  1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
> b/drivers/media/pci/ddbridge/ddbridge-core.c
> index 4a2819d3e225..080e2189ca7f 100644
> --- a/drivers/media/pci/ddbridge/ddbridge-core.c
> +++ b/drivers/media/pci/ddbridge/ddbridge-core.c
> @@ -458,13 +458,12 @@ static void calc_con(struct ddb_output *output, u32 
> *con, u32 *con2, u32 flags)
>   *con2 = (nco << 16) | gap;
>  }
>  
> -static void ddb_output_start(struct ddb_output *output)
> +static void __ddb_output_start(struct ddb_output *output)
>  {
>   struct ddb *dev = output->port->dev;
>   u32 con = 0x11c, con2 = 0;
>  
>   if (output->dma) {
> - spin_lock_irq(>dma->lock);
>   output->dma->cbuf = 0;
>   output->dma->coff = 0;
>   output->dma->stat = 0;
> @@ -492,9 +491,18 @@ static void ddb_output_start(struct ddb_output *output)
>  
>   ddbwritel(dev, con | 1, TS_CONTROL(output));
>  
> - if (output->dma) {
> + if (output->dma)
>   output->dma->running = 1;
> +}
> +
> +static void ddb_output_start(struct ddb_output *output)
> +{
> + if (output->dma) {
> + spin_lock_irq(>dma->lock);
> + __ddb_output_start(output);
>   spin_unlock_irq(>dma->lock);
> + } else {
> + __ddb_output_start(output);
>   }
>  }

This makes things look rather strange (at least to my eyes), especially
when simply trying to satisfy automated checkers, which in this case is
useless since both lock and unlock will always happen based on the same
condition ([input|output]->dma != NULL). Though I agree having the
locking inside a condition in it's current form isn't optimal, too, and
I also already thought about this in the past.

I'd rather try to fix this by checking for the dma ptrs at the
beginning of the four functions and immediately return if the ptr is
invalid. Though I don't know if this may cause side effects as there's
data written to the regs pointed by the TS_CONTROL() macros even if
there's no dma ptr present.

I'd like to hear Ralph's opinion on this, and also like to have this
changed (in whatever way) in the upstream (dddvb) repository, too.

Please refrain from applying this patch until we agreed on a proper
solution that works for everyone.

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH v2 02/19] [media] dvb-frontends/stv0910: fix CNR reporting in read_snr()

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The CNR value determined in read_snr() is reported via the wrong variable.
It uses FE_SCALE_DECIBEL, which implies the value to be reported in svalue
instead of uvalue. Fix this accordingly.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/dvb-frontends/stv0910.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index f5b5ce971c0c..1d96ae9f9f6e 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1326,7 +1326,7 @@ static int read_snr(struct dvb_frontend *fe)
 
if (!get_signal_to_noise(state, )) {
p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
-   p->cnr.stat[0].uvalue = 100 * snrval; /* fix scale */
+   p->cnr.stat[0].svalue = 100 * snrval; /* fix scale */
} else {
p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
-- 
2.16.1



[PATCH v2 05/19] [media] ddbridge: move MSI IRQ cleanup to a helper function

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Introduce the ddb_msi_exit() helper to be used for cleaning up previously
allocated MSI IRQ vectors. Deduplicates code and makes things look
cleaner as for all cleanup work the CONFIG_PCI_MSI ifdeffery is only
needed in the helper now. Also, replace the call to the deprecated
pci_disable_msi() function with pci_free_irq_vectors().

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-main.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 7088162af9d3..77089081db1f 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -65,16 +65,20 @@ static void ddb_irq_disable(struct ddb *dev)
ddbwritel(dev, 0, MSI1_ENABLE);
 }
 
+static void ddb_msi_exit(struct ddb *dev)
+{
+#ifdef CONFIG_PCI_MSI
+   if (dev->msi)
+   pci_free_irq_vectors(dev->pdev);
+#endif
+}
+
 static void ddb_irq_exit(struct ddb *dev)
 {
ddb_irq_disable(dev);
if (dev->msi == 2)
free_irq(dev->pdev->irq + 1, dev);
free_irq(dev->pdev->irq, dev);
-#ifdef CONFIG_PCI_MSI
-   if (dev->msi)
-   pci_disable_msi(dev->pdev);
-#endif
 }
 
 static void ddb_remove(struct pci_dev *pdev)
@@ -86,6 +90,7 @@ static void ddb_remove(struct pci_dev *pdev)
ddb_i2c_release(dev);
 
ddb_irq_exit(dev);
+   ddb_msi_exit(dev);
ddb_ports_release(dev);
ddb_buffers_free(dev);
 
@@ -230,8 +235,7 @@ static int ddb_probe(struct pci_dev *pdev,
ddb_irq_exit(dev);
 fail0:
dev_err(>dev, "fail0\n");
-   if (dev->msi)
-   pci_disable_msi(dev->pdev);
+   ddb_msi_exit(dev);
 fail:
dev_err(>dev, "fail\n");
 
-- 
2.16.1



[PATCH v2 17/19] [media] ddbridge: add hardware defs and PCI IDs for MCI cards

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Add PCI IDs and ddb_info for the new MCI-based MaxSX8 cards. Also add
needed defines so the cards can be hooked up into ddbridge's probe and
attach handling.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-hw.c   | 11 +++
 drivers/media/pci/ddbridge/ddbridge-main.c |  1 +
 drivers/media/pci/ddbridge/ddbridge.h  | 11 +++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c 
b/drivers/media/pci/ddbridge/ddbridge-hw.c
index c6d14925e2fc..1d3ee6accdd5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.c
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -311,6 +311,16 @@ static const struct ddb_info ddb_s2_48 = {
.tempmon_irq = 24,
 };
 
+static const struct ddb_info ddb_s2x_48 = {
+   .type = DDB_OCTOPUS_MCI,
+   .name = "Digital Devices MAX SX8",
+   .regmap   = _map,
+   .port_num = 4,
+   .i2c_mask = 0x00,
+   .tempmon_irq = 24,
+   .mci  = 4
+};
+
 //
 //
 //
@@ -346,6 +356,7 @@ static const struct ddb_device_id ddb_device_ids[] = {
DDB_DEVID(0x0008, 0x0036, ddb_isdbt_8),
DDB_DEVID(0x0008, 0x0037, ddb_c2t2i_v0_8),
DDB_DEVID(0x0008, 0x0038, ddb_c2t2i_8),
+   DDB_DEVID(0x0009, 0x0025, ddb_s2x_48),
DDB_DEVID(0x0006, 0x0039, ddb_ctv7),
DDB_DEVID(0x0011, 0x0040, ddb_ci),
DDB_DEVID(0x0011, 0x0041, ddb_cis),
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 6356b48b3874..f4748cfd904b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -264,6 +264,7 @@ static const struct pci_device_id ddb_id_table[] = {
DDB_DEVICE_ANY(0x0006),
DDB_DEVICE_ANY(0x0007),
DDB_DEVICE_ANY(0x0008),
+   DDB_DEVICE_ANY(0x0009),
DDB_DEVICE_ANY(0x0011),
DDB_DEVICE_ANY(0x0012),
DDB_DEVICE_ANY(0x0013),
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index cb69021a3443..72fe33cb72b9 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -112,11 +112,12 @@ struct ddb_ids {
 
 struct ddb_info {
int   type;
-#define DDB_NONE 0
-#define DDB_OCTOPUS  1
-#define DDB_OCTOPUS_CI   2
-#define DDB_OCTOPUS_MAX  5
+#define DDB_NONE0
+#define DDB_OCTOPUS 1
+#define DDB_OCTOPUS_CI  2
+#define DDB_OCTOPUS_MAX 5
 #define DDB_OCTOPUS_MAX_CT  6
+#define DDB_OCTOPUS_MCI 9
char *name;
u32   i2c_mask;
u8port_num;
@@ -133,6 +134,7 @@ struct ddb_info {
 #define TS_QUIRK_REVERSED 2
 #define TS_QUIRK_ALT_OSC  8
u32   tempmon_irq;
+   u8mci;
const struct ddb_regmap *regmap;
 };
 
@@ -253,6 +255,7 @@ struct ddb_port {
 #define DDB_CI_EXTERNAL_XO2_B13
 #define DDB_TUNER_DVBS_STV0910_PR 14
 #define DDB_TUNER_DVBC2T2I_SONY_P 15
+#define DDB_TUNER_MCI16
 
 #define DDB_TUNER_XO232
 #define DDB_TUNER_DVBS_STV0910   (DDB_TUNER_XO2 + 0)
-- 
2.16.1



[PATCH v2 07/19] [media] ddbridge: add helper for IRQ handler setup

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Introduce the ddb_irq_set() helper function (along with a matching
prototype in ddbridge.h) to improve the set up of the IRQ handlers
and handler_data, and rework storing this data into the ddb_link
using a new ddb_irq struct. This also does the necessary rework
of affected variables. And while at it, always do queue_work in
input_handler() as there's not much of a difference to directly
calling input_work if there's no ptr at input->redi, or queueing
this call.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 53 +-
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |  5 ++-
 drivers/media/pci/ddbridge/ddbridge.h  | 11 +--
 3 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index fb9a2cb758e6..be6935bd0cb5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -108,6 +108,16 @@ static struct ddb *ddbs[DDB_MAX_ADAPTER];
 //
 //
 
+struct ddb_irq *ddb_irq_set(struct ddb *dev, u32 link, u32 nr,
+   void (*handler)(void *), void *data)
+{
+   struct ddb_irq *irq = >link[link].irq[nr];
+
+   irq->handler = handler;
+   irq->data = data;
+   return irq;
+}
+
 static void ddb_set_dma_table(struct ddb_io *io)
 {
struct ddb *dev = io->port->dev;
@@ -2109,26 +2119,18 @@ static void input_work(struct work_struct *work)
spin_unlock_irqrestore(>lock, flags);
 }
 
-static void input_handler(unsigned long data)
+static void input_handler(void *data)
 {
struct ddb_input *input = (struct ddb_input *)data;
struct ddb_dma *dma = input->dma;
 
-   /*
-* If there is no input connected, input_tasklet() will
-* just copy pointers and ACK. So, there is no need to go
-* through the tasklet scheduler.
-*/
-   if (input->redi)
-   queue_work(ddb_wq, >work);
-   else
-   input_work(>work);
+   queue_work(ddb_wq, >work);
 }
 
-static void output_handler(unsigned long data)
+static void output_work(struct work_struct *work)
 {
-   struct ddb_output *output = (struct ddb_output *)data;
-   struct ddb_dma *dma = output->dma;
+   struct ddb_dma *dma = container_of(work, struct ddb_dma, work);
+   struct ddb_output *output = (struct ddb_output *)dma->io;
struct ddb *dev = output->port->dev;
 
spin_lock(>lock);
@@ -2144,6 +2146,14 @@ static void output_handler(unsigned long data)
spin_unlock(>lock);
 }
 
+static void output_handler(void *data)
+{
+   struct ddb_output *output = (struct ddb_output *)data;
+   struct ddb_dma *dma = output->dma;
+
+   queue_work(ddb_wq, >work);
+}
+
 //
 //
 
@@ -2174,6 +2184,7 @@ static void ddb_dma_init(struct ddb_io *io, int nr, int 
out)
spin_lock_init(>lock);
init_waitqueue_head(>wq);
if (out) {
+   INIT_WORK(>work, output_work);
dma->regs = rm->odma->base + rm->odma->size * nr;
dma->bufregs = rm->odma_buf->base + rm->odma_buf->size * nr;
dma->num = OUTPUT_DMA_BUFS;
@@ -2218,8 +2229,7 @@ static void ddb_input_init(struct ddb_port *port, int nr, 
int pnr, int anr)
dev_dbg(dev->dev, "init link %u, input %u, handler %u\n",
port->lnr, nr, dma_nr + base);
 
-   dev->handler[0][dma_nr + base] = input_handler;
-   dev->handler_data[0][dma_nr + base] = (unsigned long)input;
+   ddb_irq_set(dev, 0, dma_nr + base, _handler, input);
ddb_dma_init(input, dma_nr, 0);
}
 }
@@ -2244,8 +2254,7 @@ static void ddb_output_init(struct ddb_port *port, int nr)
const struct ddb_regmap *rm0 = io_regmap(output, 0);
u32 base = rm0->irq_base_odma;
 
-   dev->handler[0][nr + base] = output_handler;
-   dev->handler_data[0][nr + base] = (unsigned long)output;
+   ddb_irq_set(dev, 0, nr + base, _handler, output);
ddb_dma_init(output, nr, 1);
}
 }
@@ -2389,8 +2398,9 @@ void ddb_ports_release(struct ddb *dev)
 //
 
 #define IRQ_HANDLE(_nr) \
-   do { if ((s & (1UL << ((_nr) & 0x1f))) && dev->handler

[PATCH v2 08/19] [media] ddbridge: add macros to handle IRQs in nibble and byte blocks

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Currently, each IRQ requires one IRQ_HANDLE() line to call each IRQ
handler that was set up. Add a IRQ_HANDLE_NIBBLE() and IRQ_HANDLE_BYTE()
macro to call all handlers in blocks of four (_NIBBLE) or eight (_BYTE)
handlers at a time, to make this construct more compact.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 67 --
 1 file changed, 27 insertions(+), 40 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index be6935bd0cb5..5fbb0996a12c 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2403,54 +2403,41 @@ void ddb_ports_release(struct ddb *dev)
dev->link[0].irq[_nr].handler(dev->link[0].irq[_nr].data); } \
while (0)
 
+#define IRQ_HANDLE_NIBBLE(_shift) { \
+   if (s & (0x000f << ((_shift) & 0x1f))) { \
+   IRQ_HANDLE(0 + (_shift));\
+   IRQ_HANDLE(1 + (_shift));\
+   IRQ_HANDLE(2 + (_shift));\
+   IRQ_HANDLE(3 + (_shift));\
+   }\
+}
+
+#define IRQ_HANDLE_BYTE(_shift) {   \
+   if (s & (0x00ff << ((_shift) & 0x1f))) { \
+   IRQ_HANDLE(0 + (_shift));\
+   IRQ_HANDLE(1 + (_shift));\
+   IRQ_HANDLE(2 + (_shift));\
+   IRQ_HANDLE(3 + (_shift));\
+   IRQ_HANDLE(4 + (_shift));\
+   IRQ_HANDLE(5 + (_shift));\
+   IRQ_HANDLE(6 + (_shift));\
+   IRQ_HANDLE(7 + (_shift));\
+   }\
+}
+
 static void irq_handle_msg(struct ddb *dev, u32 s)
 {
dev->i2c_irq++;
-   IRQ_HANDLE(0);
-   IRQ_HANDLE(1);
-   IRQ_HANDLE(2);
-   IRQ_HANDLE(3);
+   IRQ_HANDLE_NIBBLE(0);
 }
 
 static void irq_handle_io(struct ddb *dev, u32 s)
 {
dev->ts_irq++;
-   if ((s & 0x00f0)) {
-   IRQ_HANDLE(4);
-   IRQ_HANDLE(5);
-   IRQ_HANDLE(6);
-   IRQ_HANDLE(7);
-   }
-   if ((s & 0xff00)) {
-   IRQ_HANDLE(8);
-   IRQ_HANDLE(9);
-   IRQ_HANDLE(10);
-   IRQ_HANDLE(11);
-   IRQ_HANDLE(12);
-   IRQ_HANDLE(13);
-   IRQ_HANDLE(14);
-   IRQ_HANDLE(15);
-   }
-   if ((s & 0x00ff)) {
-   IRQ_HANDLE(16);
-   IRQ_HANDLE(17);
-   IRQ_HANDLE(18);
-   IRQ_HANDLE(19);
-   IRQ_HANDLE(20);
-   IRQ_HANDLE(21);
-   IRQ_HANDLE(22);
-   IRQ_HANDLE(23);
-   }
-   if ((s & 0xff00)) {
-   IRQ_HANDLE(24);
-   IRQ_HANDLE(25);
-   IRQ_HANDLE(26);
-   IRQ_HANDLE(27);
-   IRQ_HANDLE(28);
-   IRQ_HANDLE(29);
-   IRQ_HANDLE(30);
-   IRQ_HANDLE(31);
-   }
+   IRQ_HANDLE_NIBBLE(4);
+   IRQ_HANDLE_BYTE(8);
+   IRQ_HANDLE_BYTE(16);
+   IRQ_HANDLE_BYTE(24);
 }
 
 irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
-- 
2.16.1



[PATCH v2 12/19] [media] ddbridge: set devid entry for link 0

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Currently, /sys/class/ddbridgeX/devid always reports 0 due to devid not
being set at all. Set the devid field alongside while storing all other
hardware ID data.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 008be9066814..6356b48b3874 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -198,6 +198,7 @@ static int ddb_probe(struct pci_dev *pdev,
dev->link[0].ids.device = id->device;
dev->link[0].ids.subvendor = id->subvendor;
dev->link[0].ids.subdevice = pdev->subsystem_device;
+   dev->link[0].ids.devid = (id->device << 16) | id->vendor;
 
dev->link[0].dev = dev;
dev->link[0].info = get_ddb_info(id->vendor, id->device,
-- 
2.16.1



[PATCH v2 15/19] [media] ddbridge: initial support for MCI-based MaxSX8 cards

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

This adds initial support for the new MCI-based (micro-code interface)
DD cards, with the first one being the MaxSX8 eight-tuner DVB-S/S2/S2X
PCIe card. The MCI is basically a generalized interface implemented in
the card's FPGA firmware and usable for all kind of cards, without the
need to implement any demod/tuner drivers as this interface "hides" any
I2C interface to the actual ICs, in other words any required driver is
implemented in the card firmware.

At this stage, the MCI interface is quite rudimentary with things like
signal statistics reporting missing, but is already working to serve
DVB streams to DVB applications. Missing functionality will be enabled
over time.

This implements only the ddbridge-mci sub-object and hooks it up to the
Makefile so the object gets build. The upcoming commits hook this module
into all other ddbridge parts where required, including device IDs etc.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/Makefile   |   2 +-
 drivers/media/pci/ddbridge/ddbridge-mci.c | 550 ++
 drivers/media/pci/ddbridge/ddbridge-mci.h | 152 +
 3 files changed, 703 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.h

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index 745b37d07558..9b9e35f171b7 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -4,7 +4,7 @@
 #
 
 ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \
-   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o
+   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o ddbridge-mci.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
new file mode 100644
index ..214b301f30a5
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -0,0 +1,550 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ddbridge-mci.c: Digital Devices microcode interface
+ *
+ * Copyright (C) 2017 Digital Devices GmbH
+ *Ralph Metzler <r...@metzlerbros.de>
+ *Marcus Metzler <m...@metzlerbros.de>
+ *
+ * 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 "ddbridge.h"
+#include "ddbridge-io.h"
+#include "ddbridge-mci.h"
+
+static LIST_HEAD(mci_list);
+
+static const u32 MCLK = (155000 / 12);
+static const u32 MAX_DEMOD_LDPC_BITRATE = (155000 / 6);
+static const u32 MAX_LDPC_BITRATE = (72000);
+
+struct mci_base {
+   struct list_head mci_list;
+   void*key;
+   struct ddb_link *link;
+   struct completioncompletion;
+
+   struct device   *dev;
+   struct mutex tuner_lock; /* concurrent tuner access lock */
+   u8   adr;
+   struct mutex mci_lock; /* concurrent MCI access lock */
+   int  count;
+
+   u8   tuner_use_count[4];
+   u8   assigned_demod[8];
+   u32  used_ldpc_bitrate[8];
+   u8   demod_in_use[8];
+   u32  iq_mode;
+};
+
+struct mci {
+   struct mci_base *base;
+   struct dvb_frontend  fe;
+   int  nr;
+   int  demod;
+   int  tuner;
+   int  first_time_lock;
+   int  started;
+   struct mci_resultsignal_info;
+
+   u32  bb_mode;
+};
+
+static int mci_reset(struct mci *state)
+{
+   struct ddb_link *link = state->base->link;
+   u32 status = 0;
+   u32 timeout = 40;
+
+   ddblwritel(link, MCI_CONTROL_RESET, MCI_CONTROL);
+   ddblwritel(link, 0, MCI_CONTROL + 4); /* 1= no internal init */
+   msleep(300);
+   ddblwritel(link, 0, MCI_CONTROL);
+
+   while (1) {
+   status = ddblreadl(link, MCI_CONTROL);
+   if ((status & MCI_CONTROL_READY) == MCI_CONTROL_READY)
+   break;
+   if (--timeout == 0)
+   break;
+   msleep(50);
+   }
+   if ((status & MCI_CONTROL_READY) == 0)
+   return -1;
+   if (link->ids.device == 0x0009)
+   ddblwritel(

[PATCH v2 13/19] [media] ddbridge: make DMA buffer count and size modparam-configurable

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Make the number of DMA buffers and their size configurable using module
parameters. Being able to set these to a higher number might help on
busy systems when handling overall high data rates without having to
edit the driver sources and recompile things.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 30 --
 drivers/media/pci/ddbridge/ddbridge.h  | 12 
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index e9c2e3e5d64b..8907551b02e4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -96,6 +96,15 @@ static int stv0910_single;
 module_param(stv0910_single, int, 0444);
 MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
 
+static int dma_buf_num = 8;
+module_param(dma_buf_num, int, 0444);
+MODULE_PARM_DESC(dma_buf_num, "Number of DMA buffers, possible values: 8-32");
+
+static int dma_buf_size = 21;
+module_param(dma_buf_size, int, 0444);
+MODULE_PARM_DESC(dma_buf_size,
+"DMA buffer size as multiple of 128*47, possible values: 
1-43");
+
 //
 
 static DEFINE_MUTEX(redirect_lock);
@@ -2187,16 +2196,16 @@ static void ddb_dma_init(struct ddb_io *io, int nr, int 
out)
INIT_WORK(>work, output_work);
dma->regs = rm->odma->base + rm->odma->size * nr;
dma->bufregs = rm->odma_buf->base + rm->odma_buf->size * nr;
-   dma->num = OUTPUT_DMA_BUFS;
-   dma->size = OUTPUT_DMA_SIZE;
-   dma->div = OUTPUT_DMA_IRQ_DIV;
+   dma->num = dma_buf_num;
+   dma->size = dma_buf_size * 128 * 47;
+   dma->div = 1;
} else {
INIT_WORK(>work, input_work);
dma->regs = rm->idma->base + rm->idma->size * nr;
dma->bufregs = rm->idma_buf->base + rm->idma_buf->size * nr;
-   dma->num = INPUT_DMA_BUFS;
-   dma->size = INPUT_DMA_SIZE;
-   dma->div = INPUT_DMA_IRQ_DIV;
+   dma->num = dma_buf_num;
+   dma->size = dma_buf_size * 128 * 47;
+   dma->div = 1;
}
ddbwritel(io->port->dev, 0, DMA_BUFFER_ACK(dma));
dev_dbg(io->port->dev->dev, "init link %u, io %u, dma %u, dmaregs %08x 
bufregs %08x\n",
@@ -3353,6 +3362,15 @@ int ddb_exit_ddbridge(int stage, int error)
 
 int ddb_init_ddbridge(void)
 {
+   if (dma_buf_num < 8)
+   dma_buf_num = 8;
+   if (dma_buf_num > 32)
+   dma_buf_num = 32;
+   if (dma_buf_size < 1)
+   dma_buf_size = 1;
+   if (dma_buf_size > 43)
+   dma_buf_size = 43;
+
if (ddb_class_create() < 0)
return -1;
ddb_wq = alloc_workqueue("ddbridge", 0, 0);
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index de9ddf1068bf..86db6f19369a 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -136,20 +136,8 @@ struct ddb_info {
const struct ddb_regmap *regmap;
 };
 
-/* DMA_SIZE MUST be smaller than 256k and
- * MUST be divisible by 188 and 128 !!!
- */
-
 #define DMA_MAX_BUFS 32  /* hardware table limit */
 
-#define INPUT_DMA_BUFS 8
-#define INPUT_DMA_SIZE (128 * 47 * 21)
-#define INPUT_DMA_IRQ_DIV 1
-
-#define OUTPUT_DMA_BUFS 8
-#define OUTPUT_DMA_SIZE (128 * 47 * 21)
-#define OUTPUT_DMA_IRQ_DIV 1
-
 struct ddb;
 struct ddb_port;
 
-- 
2.16.1



[PATCH v2 14/19] [media] ddbridge: support dummy tuners with 125MByte/s dummy data stream

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The Octopus V3 and Octopus Mini devices support set up of a dummy tuner
mode on port 0 that will deliver a continuous data stream of 125MBytes
per second while raising IRQs and filling the DMA buffers, which comes
handy for some stress, PCIe link and IRQ handling testing. The dummy
frontend is registered using dvb_dummy_fe's QAM dummy frontend. Set
ddbridge.dummy_tuner to 1 to enable this on the supported cards.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/Kconfig |  1 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 36 ++
 drivers/media/pci/ddbridge/ddbridge.h  |  1 +
 3 files changed, 38 insertions(+)

diff --git a/drivers/media/pci/ddbridge/Kconfig 
b/drivers/media/pci/ddbridge/Kconfig
index a422dde2f34a..16faef265e97 100644
--- a/drivers/media/pci/ddbridge/Kconfig
+++ b/drivers/media/pci/ddbridge/Kconfig
@@ -14,6 +14,7 @@ config DVB_DDBRIDGE
select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
select DVB_MXL5XX if MEDIA_SUBDRV_AUTOSELECT
select DVB_CXD2099 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_DUMMY_FE if MEDIA_SUBDRV_AUTOSELECT
---help---
  Support for cards with the Digital Devices PCI express bridge:
  - Octopus PCIe Bridge
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 8907551b02e4..59e137516003 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -54,6 +54,7 @@
 #include "stv6111.h"
 #include "lnbh25.h"
 #include "cxd2099.h"
+#include "dvb_dummy_fe.h"
 
 //
 
@@ -105,6 +106,11 @@ module_param(dma_buf_size, int, 0444);
 MODULE_PARM_DESC(dma_buf_size,
 "DMA buffer size as multiple of 128*47, possible values: 
1-43");
 
+static int dummy_tuner;
+module_param(dummy_tuner, int, 0444);
+MODULE_PARM_DESC(dummy_tuner,
+"attach dummy tuner to port 0 on Octopus V3 or Octopus Mini 
cards");
+
 //
 
 static DEFINE_MUTEX(redirect_lock);
@@ -548,6 +554,9 @@ static void ddb_input_start(struct ddb_input *input)
 
ddbwritel(dev, 0x09, TS_CONTROL(input));
 
+   if (input->port->type == DDB_TUNER_DUMMY)
+   ddbwritel(dev, 0x000fff01, TS_CONTROL2(input));
+
if (input->dma) {
input->dma->running = 1;
spin_unlock_irq(>dma->lock);
@@ -1255,6 +1264,20 @@ static int tuner_attach_stv6111(struct ddb_input *input, 
int type)
return 0;
 }
 
+static int demod_attach_dummy(struct ddb_input *input)
+{
+   struct ddb_dvb *dvb = >port->dvb[input->nr & 1];
+   struct device *dev = input->port->dev->dev;
+
+   dvb->fe = dvb_attach(dvb_dummy_fe_qam_attach);
+   if (!dvb->fe) {
+   dev_err(dev, "QAM dummy attach failed!\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
 static int start_feed(struct dvb_demux_feed *dvbdmxfeed)
 {
struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
@@ -1547,6 +1570,10 @@ static int dvb_input_attach(struct ddb_input *input)
if (tuner_attach_tda18212(input, port->type) < 0)
goto err_tuner;
break;
+   case DDB_TUNER_DUMMY:
+   if (demod_attach_dummy(input) < 0)
+   goto err_detach;
+   break;
default:
return 0;
}
@@ -1809,6 +1836,15 @@ static void ddb_port_probe(struct ddb_port *port)
 
/* Handle missing ports and ports without I2C */
 
+   if (dummy_tuner && !port->nr &&
+   dev->link[0].ids.device == 0x0005) {
+   port->name = "DUMMY";
+   port->class = DDB_PORT_TUNER;
+   port->type = DDB_TUNER_DUMMY;
+   port->type_name = "DUMMY";
+   return;
+   }
+
if (port->nr == ts_loop) {
port->name = "TS LOOP";
port->class = DDB_PORT_LOOP;
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 86db6f19369a..cb69021a3443 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -236,6 +236,7 @@ struct ddb_port {
char   *name;
char   *type_name;
u32 type;
+#define DDB_TUNER_DUMMY  0x
 #define DDB_TUNER_NONE   0
 #define DDB_TUNER_DVBS_ST1
 #define DDB_TUNER_DVBS_ST_AA 2
-- 
2.16.1



[PATCH v2 19/19] [media] ddbridge: set driver version to 0.9.33-integrated

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Set DDBRIDGE_VERSION in ddbridge.h to 0.9.33-integrated to reflect the
updated driver.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 72fe33cb72b9..a66b1125cc74 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -63,7 +63,7 @@
 #include 
 #include 
 
-#define DDBRIDGE_VERSION "0.9.32-integrated"
+#define DDBRIDGE_VERSION "0.9.33-integrated"
 
 #define DDB_MAX_I2C32
 #define DDB_MAX_PORT   32
-- 
2.16.1



[PATCH v2 18/19] [media] ddbridge: recognize and attach the MaxSX8 cards

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Add needed logic into dvb_input_attach(), ddb_port_probe() and
ddb_ports_init() to initialize and support these new cards.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 59e137516003..4a2819d3e225 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1574,6 +1574,10 @@ static int dvb_input_attach(struct ddb_input *input)
if (demod_attach_dummy(input) < 0)
goto err_detach;
break;
+   case DDB_TUNER_MCI:
+   if (ddb_fe_attach_mci(input) < 0)
+   goto err_detach;
+   break;
default:
return 0;
}
@@ -1869,6 +1873,16 @@ static void ddb_port_probe(struct ddb_port *port)
return;
}
 
+   if (dev->link[l].info->type == DDB_OCTOPUS_MCI) {
+   if (port->nr >= dev->link[l].info->mci)
+   return;
+   port->name = "DUAL MCI";
+   port->type_name = "MCI";
+   port->class = DDB_PORT_TUNER;
+   port->type = DDB_TUNER_MCI;
+   return;
+   }
+
if (port->nr > 1 && dev->link[l].info->type == DDB_OCTOPUS_CI) {
port->name = "CI internal";
port->type_name = "INTERNAL";
@@ -2411,6 +2425,7 @@ void ddb_ports_init(struct ddb *dev)
break;
case DDB_OCTOPUS_MAX:
case DDB_OCTOPUS_MAX_CT:
+   case DDB_OCTOPUS_MCI:
ddb_input_init(port, 2 * i, 0, 2 * p);
ddb_input_init(port, 2 * i + 1, 1, 2 * p + 1);
break;
-- 
2.16.1



[PATCH v2 10/19] [media] ddbridge: use spin_lock_irqsave() in output_work()

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Make sure to save IRQ states before taking the dma lock, as already done
in it's input_work() counterpart.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 9d91221dacc4..c22537eceee5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2132,18 +2132,18 @@ static void output_work(struct work_struct *work)
struct ddb_dma *dma = container_of(work, struct ddb_dma, work);
struct ddb_output *output = (struct ddb_output *)dma->io;
struct ddb *dev = output->port->dev;
+   unsigned long flags;
 
-   spin_lock(>lock);
-   if (!dma->running) {
-   spin_unlock(>lock);
-   return;
-   }
+   spin_lock_irqsave(>lock, flags);
+   if (!dma->running)
+   goto unlock_exit;
dma->stat = ddbreadl(dev, DMA_BUFFER_CURRENT(dma));
dma->ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(dma));
if (output->redi)
output_ack_input(output, output->redi);
wake_up(>wq);
-   spin_unlock(>lock);
+unlock_exit:
+   spin_unlock_irqrestore(>lock, flags);
 }
 
 static void output_handler(void *data)
-- 
2.16.1



[PATCH v2 11/19] [media] ddbridge: fix output buffer check

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

A 188 byte gap has to be left between the writer and the consumer. This
requires 2*188 bytes available to be able to write to the output buffers.
So, change ddb_output_free() to report free bytes according to this rule.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index c22537eceee5..e9c2e3e5d64b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -587,12 +587,12 @@ static u32 ddb_output_free(struct ddb_output *output)
 
if (output->dma->cbuf != idx) {
if output->dma->cbuf + 1) % output->dma->num) == idx) &&
-   (output->dma->size - output->dma->coff <= 188))
+   (output->dma->size - output->dma->coff <= (2 * 188)))
return 0;
return 188;
}
diff = off - output->dma->coff;
-   if (diff <= 0 || diff > 188)
+   if (diff <= 0 || diff > (2 * 188))
return 188;
return 0;
 }
-- 
2.16.1



[PATCH v2 16/19] [media] ddbridge/max: implement MCI/MaxSX8 attach function

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Implement frontend attachment as ddb_fe_attach_mci() into the
ddbridge-max module. The MaxSX8 MCI cards are part of the Max card series
and make use of the LNB controller driven by the already existing lnb
functionality, so here's where this code belongs to.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-max.c | 42 +++
 drivers/media/pci/ddbridge/ddbridge-max.h |  1 +
 2 files changed, 43 insertions(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c 
b/drivers/media/pci/ddbridge/ddbridge-max.c
index dc6b81488746..739e4b444cf4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.c
+++ b/drivers/media/pci/ddbridge/ddbridge-max.c
@@ -33,6 +33,7 @@
 #include "ddbridge.h"
 #include "ddbridge-regs.h"
 #include "ddbridge-io.h"
+#include "ddbridge-mci.h"
 
 #include "ddbridge-max.h"
 #include "mxl5xx.h"
@@ -452,3 +453,44 @@ int ddb_fe_attach_mxl5xx(struct ddb_input *input)
dvb->input = tuner;
return 0;
 }
+
+/**/
+/* MAX MCI related functions */
+
+int ddb_fe_attach_mci(struct ddb_input *input)
+{
+   struct ddb *dev = input->port->dev;
+   struct ddb_dvb *dvb = >port->dvb[input->nr & 1];
+   struct ddb_port *port = input->port;
+   struct ddb_link *link = >link[port->lnr];
+   int demod, tuner;
+
+   demod = input->nr;
+   tuner = demod & 3;
+   if (fmode == 3)
+   tuner = 0;
+   dvb->fe = ddb_mci_attach(input, 0, demod, >set_input);
+   if (!dvb->fe) {
+   dev_err(dev->dev, "No MAXSX8 found!\n");
+   return -ENODEV;
+   }
+   if (!dvb->set_input) {
+   dev_err(dev->dev, "No MCI set_input function pointer!\n");
+   return -ENODEV;
+   }
+   if (input->nr < 4) {
+   lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT);
+   lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF);
+   }
+   ddb_lnb_init_fmode(dev, link, fmode);
+
+   dvb->fe->ops.set_voltage = max_set_voltage;
+   dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage;
+   dvb->fe->ops.set_tone = max_set_tone;
+   dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd;
+   dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd;
+   dvb->fe->ops.diseqc_send_burst = max_send_burst;
+   dvb->fe->sec_priv = input;
+   dvb->input = tuner;
+   return 0;
+}
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h 
b/drivers/media/pci/ddbridge/ddbridge-max.h
index bf8bf38739f6..82efc53baa94 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.h
+++ b/drivers/media/pci/ddbridge/ddbridge-max.h
@@ -25,5 +25,6 @@
 
 int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
 int ddb_fe_attach_mxl5xx(struct ddb_input *input);
+int ddb_fe_attach_mci(struct ddb_input *input);
 
 #endif /* _DDBRIDGE_MAX_H */
-- 
2.16.1



[PATCH v2 03/19] [media] ddbridge: move modparams to ddbridge-core.c

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Besides the 'msi' module option, all options are used from within
ddbridge-core only, so move them over from ddbridge-main, and declare the
associated variables static. Since the prototypes in ddbridge.h aren't
necessary anymore now, remove them. As a side effect, this has the benefit
of aligning things more with the dddvb upstream.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 28 
 drivers/media/pci/ddbridge/ddbridge-main.c | 28 
 drivers/media/pci/ddbridge/ddbridge.h  |  6 --
 3 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 90687eff5909..933046d03db5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -68,6 +68,34 @@ module_param(adapter_alloc, int, 0444);
 MODULE_PARM_DESC(adapter_alloc,
 "0-one adapter per io, 1-one per tab with io, 2-one per tab, 
3-one for all");
 
+static int ci_bitrate = 7;
+module_param(ci_bitrate, int, 0444);
+MODULE_PARM_DESC(ci_bitrate, " Bitrate in KHz for output to CI.");
+
+static int ts_loop = -1;
+module_param(ts_loop, int, 0444);
+MODULE_PARM_DESC(ts_loop, "TS in/out test loop on port ts_loop");
+
+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");
+
+#ifdef __arm__
+static int alt_dma = 1;
+#else
+static int alt_dma;
+#endif
+module_param(alt_dma, int, 0444);
+MODULE_PARM_DESC(alt_dma, "use alternative DMA buffer handling");
+
+static int no_init;
+module_param(no_init, int, 0444);
+MODULE_PARM_DESC(no_init, "do not initialize most devices");
+
+static int stv0910_single;
+module_param(stv0910_single, int, 0444);
+MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
+
 //
 
 static DEFINE_MUTEX(redirect_lock);
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 26497d6b1395..bde04dc39080 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -55,34 +55,6 @@ MODULE_PARM_DESC(msi, "Control MSI interrupts: 0-disable 
(default), 1-enable");
 #endif
 #endif
 
-int ci_bitrate = 7;
-module_param(ci_bitrate, int, 0444);
-MODULE_PARM_DESC(ci_bitrate, " Bitrate in KHz for output to CI.");
-
-int ts_loop = -1;
-module_param(ts_loop, int, 0444);
-MODULE_PARM_DESC(ts_loop, "TS in/out test loop on port ts_loop");
-
-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");
-
-#ifdef __arm__
-int alt_dma = 1;
-#else
-int alt_dma;
-#endif
-module_param(alt_dma, int, 0444);
-MODULE_PARM_DESC(alt_dma, "use alternative DMA buffer handling");
-
-int no_init;
-module_param(no_init, int, 0444);
-MODULE_PARM_DESC(no_init, "do not initialize most devices");
-
-int stv0910_single;
-module_param(stv0910_single, int, 0444);
-MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
-
 //
 //
 //
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index f223dc6c9963..e22e67d7e0fe 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -369,12 +369,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, 
u32 addr, u32 len);
 //
 
 /* ddbridge-main.c (modparams) */
-extern int ci_bitrate;
-extern int ts_loop;
-extern int xo2_speed;
-extern int alt_dma;
-extern int no_init;
-extern int stv0910_single;
 extern struct workqueue_struct *ddb_wq;
 
 /* ddbridge-core.c */
-- 
2.16.1



[PATCH v2 09/19] [media] ddbridge: improve separated MSI IRQ handling

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Improve IRQ handling in the separated MSG/I2C and IO/TSDATA handlers by
applying a mask for recognized bits immediately upon reading the IRQ mask
from the hardware, so only the bits/IRQs that actually were set will be
acked.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 5fbb0996a12c..9d91221dacc4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2443,16 +2443,17 @@ static void irq_handle_io(struct ddb *dev, u32 s)
 irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
 {
struct ddb *dev = (struct ddb *)dev_id;
-   u32 s = ddbreadl(dev, INTERRUPT_STATUS);
+   u32 mask = 0x8f00;
+   u32 s = mask & ddbreadl(dev, INTERRUPT_STATUS);
 
+   if (!s)
+   return IRQ_NONE;
do {
if (s & 0x8000)
return IRQ_NONE;
-   if (!(s & 0xf00))
-   return IRQ_NONE;
-   ddbwritel(dev, s & 0xf00, INTERRUPT_ACK);
+   ddbwritel(dev, s, INTERRUPT_ACK);
irq_handle_io(dev, s);
-   } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
+   } while ((s = mask & ddbreadl(dev, INTERRUPT_STATUS)));
 
return IRQ_HANDLED;
 }
@@ -2460,16 +2461,17 @@ irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
 irqreturn_t ddb_irq_handler1(int irq, void *dev_id)
 {
struct ddb *dev = (struct ddb *)dev_id;
-   u32 s = ddbreadl(dev, INTERRUPT_STATUS);
+   u32 mask = 0x800f;
+   u32 s = mask & ddbreadl(dev, INTERRUPT_STATUS);
 
+   if (!s)
+   return IRQ_NONE;
do {
if (s & 0x8000)
return IRQ_NONE;
-   if (!(s & 0xf))
-   return IRQ_NONE;
-   ddbwritel(dev, s & 0xf, INTERRUPT_ACK);
+   ddbwritel(dev, s, INTERRUPT_ACK);
irq_handle_msg(dev, s);
-   } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
+   } while ((s = mask & ddbreadl(dev, INTERRUPT_STATUS)));
 
return IRQ_HANDLED;
 }
-- 
2.16.1



[PATCH v2 06/19] [media] ddbridge: request/free_irq using pci_irq_vector, enable MSI-X

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Instead of trying to manage IRQ numbers on itself, utilise the
pci_irq_vector() function to do this, which will take care of correct IRQ
numbering for MSI and non-MSI IRQs. While at it, request and enable MSI-X
interrupts for hardware (boards and cards) that support this.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-main.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 77089081db1f..008be9066814 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -77,8 +77,8 @@ static void ddb_irq_exit(struct ddb *dev)
 {
ddb_irq_disable(dev);
if (dev->msi == 2)
-   free_irq(dev->pdev->irq + 1, dev);
-   free_irq(dev->pdev->irq, dev);
+   free_irq(pci_irq_vector(dev->pdev, 1), dev);
+   free_irq(pci_irq_vector(dev->pdev, 0), dev);
 }
 
 static void ddb_remove(struct pci_dev *pdev)
@@ -105,7 +105,8 @@ static void ddb_irq_msi(struct ddb *dev, int nr)
int stat;
 
if (msi && pci_msi_enabled()) {
-   stat = pci_alloc_irq_vectors(dev->pdev, 1, nr, PCI_IRQ_MSI);
+   stat = pci_alloc_irq_vectors(dev->pdev, 1, nr,
+PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (stat >= 1) {
dev->msi = stat;
dev_info(dev->dev, "using %d MSI interrupt(s)\n",
@@ -137,21 +138,24 @@ static int ddb_irq_init(struct ddb *dev)
if (dev->msi)
irq_flag = 0;
if (dev->msi == 2) {
-   stat = request_irq(dev->pdev->irq, ddb_irq_handler0,
-  irq_flag, "ddbridge", (void *)dev);
+   stat = request_irq(pci_irq_vector(dev->pdev, 0),
+  ddb_irq_handler0, irq_flag, "ddbridge",
+  (void *)dev);
if (stat < 0)
return stat;
-   stat = request_irq(dev->pdev->irq + 1, ddb_irq_handler1,
-  irq_flag, "ddbridge", (void *)dev);
+   stat = request_irq(pci_irq_vector(dev->pdev, 1),
+  ddb_irq_handler1, irq_flag, "ddbridge",
+  (void *)dev);
if (stat < 0) {
-   free_irq(dev->pdev->irq, dev);
+   free_irq(pci_irq_vector(dev->pdev, 0), dev);
return stat;
}
} else
 #endif
{
-   stat = request_irq(dev->pdev->irq, ddb_irq_handler,
-  irq_flag, "ddbridge", (void *)dev);
+   stat = request_irq(pci_irq_vector(dev->pdev, 0),
+  ddb_irq_handler, irq_flag, "ddbridge",
+  (void *)dev);
if (stat < 0)
return stat;
}
-- 
2.16.1



[PATCH v2 01/19] [media] dvb-frontends/stv0910: add init values for TSINSDELM/L

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The TSINSDEL registers were lacking initialisation in the stv0910 demod
driver. Initialise them (both demods) in the probe() function.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/dvb-frontends/stv0910.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 52355c14fd64..f5b5ce971c0c 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1220,6 +1220,12 @@ static int probe(struct stv *state)
write_reg(state, RSTV0910_P1_I2CRPT, state->i2crpt);
write_reg(state, RSTV0910_P2_I2CRPT, state->i2crpt);
 
+   write_reg(state, RSTV0910_P1_TSINSDELM, 0x17);
+   write_reg(state, RSTV0910_P1_TSINSDELL, 0xff);
+
+   write_reg(state, RSTV0910_P2_TSINSDELM, 0x17);
+   write_reg(state, RSTV0910_P2_TSINSDELL, 0xff);
+
init_diseqc(state);
return 0;
 }
-- 
2.16.1



[PATCH v2 04/19] [media] ddbridge: move ddb_wq and the wq+class initialisation to -core

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Move the ddbridge module initialisation and cleanup code to ddbridge-core
and set up the ddb_wq workqueue there, and create and destroy the ddb
device class there aswell. Due to this, the prototypes for ddb_wq,
ddb_class_create() and ddb_class_destroy() aren't required in ddbridge.h
anymore, so remove them. Also, declare ddb_wq and the ddb_class_*()
functions static.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 32 +++---
 drivers/media/pci/ddbridge/ddbridge-main.c | 21 +++-
 drivers/media/pci/ddbridge/ddbridge.h  |  7 ++-
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 933046d03db5..fb9a2cb758e6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -100,7 +100,7 @@ MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as 
single demods");
 
 static DEFINE_MUTEX(redirect_lock);
 
-struct workqueue_struct *ddb_wq;
+static struct workqueue_struct *ddb_wq;
 
 static struct ddb *ddbs[DDB_MAX_ADAPTER];
 
@@ -3055,7 +3055,7 @@ static struct class ddb_class = {
.devnode= ddb_devnode,
 };
 
-int ddb_class_create(void)
+static int ddb_class_create(void)
 {
ddb_major = register_chrdev(0, DDB_NAME, _fops);
if (ddb_major < 0)
@@ -3065,7 +3065,7 @@ int ddb_class_create(void)
return 0;
 }
 
-void ddb_class_destroy(void)
+static void ddb_class_destroy(void)
 {
class_unregister(_class);
unregister_chrdev(ddb_major, DDB_NAME);
@@ -3337,3 +3337,29 @@ void ddb_unmap(struct ddb *dev)
iounmap(dev->regs);
vfree(dev);
 }
+
+int ddb_exit_ddbridge(int stage, int error)
+{
+   switch (stage) {
+   default:
+   case 2:
+   destroy_workqueue(ddb_wq);
+   /* fall-through */
+   case 1:
+   ddb_class_destroy();
+   break;
+   }
+
+   return error;
+}
+
+int ddb_init_ddbridge(void)
+{
+   if (ddb_class_create() < 0)
+   return -1;
+   ddb_wq = alloc_workqueue("ddbridge", 0, 0);
+   if (!ddb_wq)
+   return ddb_exit_ddbridge(1, -1);
+
+   return 0;
+}
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index bde04dc39080..7088162af9d3 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -282,32 +282,25 @@ static struct pci_driver ddb_pci_driver = {
 
 static __init int module_init_ddbridge(void)
 {
-   int stat = -1;
+   int stat;
 
pr_info("Digital Devices PCIE bridge driver "
DDBRIDGE_VERSION
", Copyright (C) 2010-17 Digital Devices GmbH\n");
-   if (ddb_class_create() < 0)
-   return -1;
-   ddb_wq = create_workqueue("ddbridge");
-   if (!ddb_wq)
-   goto exit1;
+   stat = ddb_init_ddbridge();
+   if (stat < 0)
+   return stat;
stat = pci_register_driver(_pci_driver);
if (stat < 0)
-   goto exit2;
-   return stat;
-exit2:
-   destroy_workqueue(ddb_wq);
-exit1:
-   ddb_class_destroy();
+   ddb_exit_ddbridge(0, stat);
+
return stat;
 }
 
 static __exit void module_exit_ddbridge(void)
 {
pci_unregister_driver(_pci_driver);
-   destroy_workqueue(ddb_wq);
-   ddb_class_destroy();
+   ddb_exit_ddbridge(0, 0);
 }
 
 module_init(module_init_ddbridge);
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index e22e67d7e0fe..dbd5f551ce76 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -368,9 +368,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, 
u32 addr, u32 len);
 
 //
 
-/* ddbridge-main.c (modparams) */
-extern struct workqueue_struct *ddb_wq;
-
 /* ddbridge-core.c */
 void ddb_ports_detach(struct ddb *dev);
 void ddb_ports_release(struct ddb *dev);
@@ -383,9 +380,9 @@ void ddb_ports_init(struct ddb *dev);
 int ddb_buffers_alloc(struct ddb *dev);
 int ddb_ports_attach(struct ddb *dev);
 int ddb_device_create(struct ddb *dev);
-int ddb_class_create(void);
-void ddb_class_destroy(void);
 int ddb_init(struct ddb *dev);
 void ddb_unmap(struct ddb *dev);
+int ddb_exit_ddbridge(int stage, int error);
+int ddb_init_ddbridge(void);
 
 #endif /* DDBRIDGE_H */
-- 
2.16.1



[PATCH v2 00/19] dddvb/ddbridge-0.9.33

2018-04-09 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

This series brings all relevant changes from the upstream dddvb-0.9.33
driver package to the in-kernel ddbridge and stv0910, though a few changes
were picked up and merged previously already.

Summary of changes:
* stv0910: initialisation fixes and fixed CNR reporting (uvalue vs.
  svalue)
* ddbridge: general code move, cleanups and fixups
* ddbridge: fixes and improvements to the IRQ setup and handling, and
  MSI-X support
* ddbridge: configurable DMA buffers (via modparam)
* ddbridge: dummy tuner option, useful for debugging and stress testing
  purposes
* ddbridge: support for the new MCI card types, and namely the new MaxSX8
  cards

Patches were build-tested in their order and are bisect safe. Besides the
modparam move, everything is picked up from dddvb-0.9.33.

The series adds the new ddbridge-mci.[c|h] files. Here, SPDX headers were
already put in place, but until things have been fully sorted out, the
original GPL boiler plate is kept in place for now.

Changes since v1:
* The "stv0910: increase parallel TS output speed" commit was deleted,
  as it causes non-working cineS2V7 cards with older card/FPGA firmware.

Please pick up and merge.

Daniel Scheller (19):
  [media] dvb-frontends/stv0910: add init values for TSINSDELM/L
  [media] dvb-frontends/stv0910: fix CNR reporting in read_snr()
  [media] ddbridge: move modparams to ddbridge-core.c
  [media] ddbridge: move ddb_wq and the wq+class initialisation to -core
  [media] ddbridge: move MSI IRQ cleanup to a helper function
  [media] ddbridge: request/free_irq using pci_irq_vector, enable MSI-X
  [media] ddbridge: add helper for IRQ handler setup
  [media] ddbridge: add macros to handle IRQs in nibble and byte blocks
  [media] ddbridge: improve separated MSI IRQ handling
  [media] ddbridge: use spin_lock_irqsave() in output_work()
  [media] ddbridge: fix output buffer check
  [media] ddbridge: set devid entry for link 0
  [media] ddbridge: make DMA buffer count and size modparam-configurable
  [media] ddbridge: support dummy tuners with 125MByte/s dummy data
stream
  [media] ddbridge: initial support for MCI-based MaxSX8 cards
  [media] ddbridge/max: implement MCI/MaxSX8 attach function
  [media] ddbridge: add hardware defs and PCI IDs for MCI cards
  [media] ddbridge: recognize and attach the MaxSX8 cards
  [media] ddbridge: set driver version to 0.9.33-integrated

 drivers/media/dvb-frontends/stv0910.c  |   8 +-
 drivers/media/pci/ddbridge/Kconfig |   1 +
 drivers/media/pci/ddbridge/Makefile|   2 +-
 drivers/media/pci/ddbridge/ddbridge-core.c | 299 +++-
 drivers/media/pci/ddbridge/ddbridge-hw.c   |  11 +
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |   5 +-
 drivers/media/pci/ddbridge/ddbridge-main.c |  91 ++---
 drivers/media/pci/ddbridge/ddbridge-max.c  |  42 +++
 drivers/media/pci/ddbridge/ddbridge-max.h  |   1 +
 drivers/media/pci/ddbridge/ddbridge-mci.c  | 550 +
 drivers/media/pci/ddbridge/ddbridge-mci.h  | 152 
 drivers/media/pci/ddbridge/ddbridge.h  |  50 +--
 12 files changed, 1029 insertions(+), 183 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.h

-- 
2.16.1



Re: [PATCH 00/20] dddvb/ddbridge-0.9.33

2018-04-05 Thread Daniel Scheller
Am Mon,  2 Apr 2018 20:24:07 +0200
schrieb Daniel Scheller <d.scheller@gmail.com>:

> From: Daniel Scheller <d.schel...@gmx.net>
> 
> This series brings all relevant changes from the upstream dddvb-0.9.33
> driver package to the in-kernel ddbridge and stv0910, though a few
> changes were picked up and merged previously already.
> 
> Summary of changes:
> * stv0910: initialisation fixes and fixed CNR reporting (uvalue vs.
>   svalue)
> * ddbridge: general code move, cleanups and fixups
> * ddbridge: fixes and improvements to the IRQ setup and handling, and
>   MSI-X support
> * ddbridge: configurable DMA buffers (via modparam)
> * ddbridge: dummy tuner option, useful for debugging and stress
> testing purposes
> * ddbridge: support for the new MCI card types, and namely the new
> MaxSX8 cards
> 
> Patches were build-tested in their order and are bisect safe. Besides
> the modparam move, everything is picked up from dddvb-0.9.33.
> 
> The series adds the new ddbridge-mci.[c|h] files. Here, SPDX headers
> were already put in place, but until things have been fully sorted
> out, the original GPL boiler plate is kept in place for now.
> 
> Please pick up and merge.
> 
> Daniel Scheller (20):
>   [media] dvb-frontends/stv0910: add init values for TSINSDELM/L
>   [media] dvb-frontends/stv0910: increase parallel TS output speed
>   [media] dvb-frontends/stv0910: fix CNR reporting in read_snr()
>   [media] ddbridge: move modparams to ddbridge-core.c
>   [media] ddbridge: move ddb_wq and the wq+class initialisation to
> -core [media] ddbridge: move MSI IRQ cleanup to a helper function
>   [media] ddbridge: request/free_irq using pci_irq_vector, enable
> MSI-X [media] ddbridge: add helper for IRQ handler setup
>   [media] ddbridge: add macros to handle IRQs in nibble and byte
> blocks [media] ddbridge: improve separated MSI IRQ handling
>   [media] ddbridge: use spin_lock_irqsave() in output_work()
>   [media] ddbridge: fix output buffer check
>   [media] ddbridge: set devid entry for link 0
>   [media] ddbridge: make DMA buffer count and size
> modparam-configurable [media] ddbridge: support dummy tuners with
> 125MByte/s dummy data stream
>   [media] ddbridge: initial support for MCI-based MaxSX8 cards
>   [media] ddbridge/max: implement MCI/MaxSX8 attach function
>   [media] ddbridge: add hardware defs and PCI IDs for MCI cards
>   [media] ddbridge: recognize and attach the MaxSX8 cards
>   [media] ddbridge: set driver version to 0.9.33-integrated
> 
>  drivers/media/dvb-frontends/stv0910.c  |  12 +-
>  drivers/media/pci/ddbridge/Kconfig |   1 +
>  drivers/media/pci/ddbridge/Makefile|   2 +-
>  drivers/media/pci/ddbridge/ddbridge-core.c | 299 +++-
>  drivers/media/pci/ddbridge/ddbridge-hw.c   |  11 +
>  drivers/media/pci/ddbridge/ddbridge-i2c.c  |   5 +-
>  drivers/media/pci/ddbridge/ddbridge-main.c |  91 ++---
>  drivers/media/pci/ddbridge/ddbridge-max.c  |  42 +++
>  drivers/media/pci/ddbridge/ddbridge-max.h  |   1 +
>  drivers/media/pci/ddbridge/ddbridge-mci.c  | 550
> +
> drivers/media/pci/ddbridge/ddbridge-mci.h  | 152 
> drivers/media/pci/ddbridge/ddbridge.h  |  50 +-- 12 files
> changed, 1030 insertions(+), 186 deletions(-) create mode 100644
> drivers/media/pci/ddbridge/ddbridge-mci.c create mode 100644
> drivers/media/pci/ddbridge/ddbridge-mci.h
> 

Please refrain from merging this as it is now. Recently, one issue has
been discovered with one of the stv0910 patches which renders at least
the CineS2 V7A cards (specifically the tuners soldered on them,
extensions will still work fine) unusable. Upstream has this issue
aswell. This is currently under investigation.

Best regards,
Daniel Scheller
-- 
https://github.com/herrnst


[PATCH 13/20] [media] ddbridge: set devid entry for link 0

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Currently, /sys/class/ddbridgeX/devid always reports 0 due to devid not
being set at all. Set the devid field alongside while storing all other
hardware ID data.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 008be9066814..6356b48b3874 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -198,6 +198,7 @@ static int ddb_probe(struct pci_dev *pdev,
dev->link[0].ids.device = id->device;
dev->link[0].ids.subvendor = id->subvendor;
dev->link[0].ids.subdevice = pdev->subsystem_device;
+   dev->link[0].ids.devid = (id->device << 16) | id->vendor;
 
dev->link[0].dev = dev;
dev->link[0].info = get_ddb_info(id->vendor, id->device,
-- 
2.16.1



[PATCH 01/20] [media] dvb-frontends/stv0910: add init values for TSINSDELM/L

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The TSINSDEL registers were lacking initialisation in the stv0910 demod
driver. Initialise them (both demods) in the probe() function.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/dvb-frontends/stv0910.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 52355c14fd64..f5b5ce971c0c 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1220,6 +1220,12 @@ static int probe(struct stv *state)
write_reg(state, RSTV0910_P1_I2CRPT, state->i2crpt);
write_reg(state, RSTV0910_P2_I2CRPT, state->i2crpt);
 
+   write_reg(state, RSTV0910_P1_TSINSDELM, 0x17);
+   write_reg(state, RSTV0910_P1_TSINSDELL, 0xff);
+
+   write_reg(state, RSTV0910_P2_TSINSDELM, 0x17);
+   write_reg(state, RSTV0910_P2_TSINSDELL, 0xff);
+
init_diseqc(state);
return 0;
 }
-- 
2.16.1



[PATCH 00/20] dddvb/ddbridge-0.9.33

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

This series brings all relevant changes from the upstream dddvb-0.9.33
driver package to the in-kernel ddbridge and stv0910, though a few changes
were picked up and merged previously already.

Summary of changes:
* stv0910: initialisation fixes and fixed CNR reporting (uvalue vs.
  svalue)
* ddbridge: general code move, cleanups and fixups
* ddbridge: fixes and improvements to the IRQ setup and handling, and
  MSI-X support
* ddbridge: configurable DMA buffers (via modparam)
* ddbridge: dummy tuner option, useful for debugging and stress testing
  purposes
* ddbridge: support for the new MCI card types, and namely the new MaxSX8
  cards

Patches were build-tested in their order and are bisect safe. Besides the
modparam move, everything is picked up from dddvb-0.9.33.

The series adds the new ddbridge-mci.[c|h] files. Here, SPDX headers were
already put in place, but until things have been fully sorted out, the
original GPL boiler plate is kept in place for now.

Please pick up and merge.

Daniel Scheller (20):
  [media] dvb-frontends/stv0910: add init values for TSINSDELM/L
  [media] dvb-frontends/stv0910: increase parallel TS output speed
  [media] dvb-frontends/stv0910: fix CNR reporting in read_snr()
  [media] ddbridge: move modparams to ddbridge-core.c
  [media] ddbridge: move ddb_wq and the wq+class initialisation to -core
  [media] ddbridge: move MSI IRQ cleanup to a helper function
  [media] ddbridge: request/free_irq using pci_irq_vector, enable MSI-X
  [media] ddbridge: add helper for IRQ handler setup
  [media] ddbridge: add macros to handle IRQs in nibble and byte blocks
  [media] ddbridge: improve separated MSI IRQ handling
  [media] ddbridge: use spin_lock_irqsave() in output_work()
  [media] ddbridge: fix output buffer check
  [media] ddbridge: set devid entry for link 0
  [media] ddbridge: make DMA buffer count and size modparam-configurable
  [media] ddbridge: support dummy tuners with 125MByte/s dummy data
stream
  [media] ddbridge: initial support for MCI-based MaxSX8 cards
  [media] ddbridge/max: implement MCI/MaxSX8 attach function
  [media] ddbridge: add hardware defs and PCI IDs for MCI cards
  [media] ddbridge: recognize and attach the MaxSX8 cards
  [media] ddbridge: set driver version to 0.9.33-integrated

 drivers/media/dvb-frontends/stv0910.c  |  12 +-
 drivers/media/pci/ddbridge/Kconfig |   1 +
 drivers/media/pci/ddbridge/Makefile|   2 +-
 drivers/media/pci/ddbridge/ddbridge-core.c | 299 +++-
 drivers/media/pci/ddbridge/ddbridge-hw.c   |  11 +
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |   5 +-
 drivers/media/pci/ddbridge/ddbridge-main.c |  91 ++---
 drivers/media/pci/ddbridge/ddbridge-max.c  |  42 +++
 drivers/media/pci/ddbridge/ddbridge-max.h  |   1 +
 drivers/media/pci/ddbridge/ddbridge-mci.c  | 550 +
 drivers/media/pci/ddbridge/ddbridge-mci.h  | 152 
 drivers/media/pci/ddbridge/ddbridge.h  |  50 +--
 12 files changed, 1030 insertions(+), 186 deletions(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.h

-- 
2.16.1



[PATCH 08/20] [media] ddbridge: add helper for IRQ handler setup

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Introduce the ddb_irq_set() helper function (along with a matching
prototype in ddbridge.h) to improve the set up of the IRQ handlers
and handler_data, and rework storing this data into the ddb_link
using a new ddb_irq struct. This also does the necessary rework
of affected variables. And while at it, always do queue_work in
input_handler() as there's not much of a difference to directly
calling input_work if there's no ptr at input->redi, or queueing
this call.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 53 +-
 drivers/media/pci/ddbridge/ddbridge-i2c.c  |  5 ++-
 drivers/media/pci/ddbridge/ddbridge.h  | 11 +--
 3 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index fb9a2cb758e6..be6935bd0cb5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -108,6 +108,16 @@ static struct ddb *ddbs[DDB_MAX_ADAPTER];
 //
 //
 
+struct ddb_irq *ddb_irq_set(struct ddb *dev, u32 link, u32 nr,
+   void (*handler)(void *), void *data)
+{
+   struct ddb_irq *irq = >link[link].irq[nr];
+
+   irq->handler = handler;
+   irq->data = data;
+   return irq;
+}
+
 static void ddb_set_dma_table(struct ddb_io *io)
 {
struct ddb *dev = io->port->dev;
@@ -2109,26 +2119,18 @@ static void input_work(struct work_struct *work)
spin_unlock_irqrestore(>lock, flags);
 }
 
-static void input_handler(unsigned long data)
+static void input_handler(void *data)
 {
struct ddb_input *input = (struct ddb_input *)data;
struct ddb_dma *dma = input->dma;
 
-   /*
-* If there is no input connected, input_tasklet() will
-* just copy pointers and ACK. So, there is no need to go
-* through the tasklet scheduler.
-*/
-   if (input->redi)
-   queue_work(ddb_wq, >work);
-   else
-   input_work(>work);
+   queue_work(ddb_wq, >work);
 }
 
-static void output_handler(unsigned long data)
+static void output_work(struct work_struct *work)
 {
-   struct ddb_output *output = (struct ddb_output *)data;
-   struct ddb_dma *dma = output->dma;
+   struct ddb_dma *dma = container_of(work, struct ddb_dma, work);
+   struct ddb_output *output = (struct ddb_output *)dma->io;
struct ddb *dev = output->port->dev;
 
spin_lock(>lock);
@@ -2144,6 +2146,14 @@ static void output_handler(unsigned long data)
spin_unlock(>lock);
 }
 
+static void output_handler(void *data)
+{
+   struct ddb_output *output = (struct ddb_output *)data;
+   struct ddb_dma *dma = output->dma;
+
+   queue_work(ddb_wq, >work);
+}
+
 //
 //
 
@@ -2174,6 +2184,7 @@ static void ddb_dma_init(struct ddb_io *io, int nr, int 
out)
spin_lock_init(>lock);
init_waitqueue_head(>wq);
if (out) {
+   INIT_WORK(>work, output_work);
dma->regs = rm->odma->base + rm->odma->size * nr;
dma->bufregs = rm->odma_buf->base + rm->odma_buf->size * nr;
dma->num = OUTPUT_DMA_BUFS;
@@ -2218,8 +2229,7 @@ static void ddb_input_init(struct ddb_port *port, int nr, 
int pnr, int anr)
dev_dbg(dev->dev, "init link %u, input %u, handler %u\n",
port->lnr, nr, dma_nr + base);
 
-   dev->handler[0][dma_nr + base] = input_handler;
-   dev->handler_data[0][dma_nr + base] = (unsigned long)input;
+   ddb_irq_set(dev, 0, dma_nr + base, _handler, input);
ddb_dma_init(input, dma_nr, 0);
}
 }
@@ -2244,8 +2254,7 @@ static void ddb_output_init(struct ddb_port *port, int nr)
const struct ddb_regmap *rm0 = io_regmap(output, 0);
u32 base = rm0->irq_base_odma;
 
-   dev->handler[0][nr + base] = output_handler;
-   dev->handler_data[0][nr + base] = (unsigned long)output;
+   ddb_irq_set(dev, 0, nr + base, _handler, output);
ddb_dma_init(output, nr, 1);
}
 }
@@ -2389,8 +2398,9 @@ void ddb_ports_release(struct ddb *dev)
 //
 
 #define IRQ_HANDLE(_nr) \
-   do { if ((s & (1UL << ((_nr) & 0x1f))) && dev->handler

[PATCH 11/20] [media] ddbridge: use spin_lock_irqsave() in output_work()

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Make sure to save IRQ states before taking the dma lock, as already done
in it's input_work() counterpart.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 9d91221dacc4..c22537eceee5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2132,18 +2132,18 @@ static void output_work(struct work_struct *work)
struct ddb_dma *dma = container_of(work, struct ddb_dma, work);
struct ddb_output *output = (struct ddb_output *)dma->io;
struct ddb *dev = output->port->dev;
+   unsigned long flags;
 
-   spin_lock(>lock);
-   if (!dma->running) {
-   spin_unlock(>lock);
-   return;
-   }
+   spin_lock_irqsave(>lock, flags);
+   if (!dma->running)
+   goto unlock_exit;
dma->stat = ddbreadl(dev, DMA_BUFFER_CURRENT(dma));
dma->ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(dma));
if (output->redi)
output_ack_input(output, output->redi);
wake_up(>wq);
-   spin_unlock(>lock);
+unlock_exit:
+   spin_unlock_irqrestore(>lock, flags);
 }
 
 static void output_handler(void *data)
-- 
2.16.1



[PATCH 17/20] [media] ddbridge/max: implement MCI/MaxSX8 attach function

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Implement frontend attachment as ddb_fe_attach_mci() into the
ddbridge-max module. The MaxSX8 MCI cards are part of the Max card series
and make use of the LNB controller driven by the already existing lnb
functionality, so here's where this code belongs to.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-max.c | 42 +++
 drivers/media/pci/ddbridge/ddbridge-max.h |  1 +
 2 files changed, 43 insertions(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-max.c 
b/drivers/media/pci/ddbridge/ddbridge-max.c
index dc6b81488746..739e4b444cf4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.c
+++ b/drivers/media/pci/ddbridge/ddbridge-max.c
@@ -33,6 +33,7 @@
 #include "ddbridge.h"
 #include "ddbridge-regs.h"
 #include "ddbridge-io.h"
+#include "ddbridge-mci.h"
 
 #include "ddbridge-max.h"
 #include "mxl5xx.h"
@@ -452,3 +453,44 @@ int ddb_fe_attach_mxl5xx(struct ddb_input *input)
dvb->input = tuner;
return 0;
 }
+
+/**/
+/* MAX MCI related functions */
+
+int ddb_fe_attach_mci(struct ddb_input *input)
+{
+   struct ddb *dev = input->port->dev;
+   struct ddb_dvb *dvb = >port->dvb[input->nr & 1];
+   struct ddb_port *port = input->port;
+   struct ddb_link *link = >link[port->lnr];
+   int demod, tuner;
+
+   demod = input->nr;
+   tuner = demod & 3;
+   if (fmode == 3)
+   tuner = 0;
+   dvb->fe = ddb_mci_attach(input, 0, demod, >set_input);
+   if (!dvb->fe) {
+   dev_err(dev->dev, "No MAXSX8 found!\n");
+   return -ENODEV;
+   }
+   if (!dvb->set_input) {
+   dev_err(dev->dev, "No MCI set_input function pointer!\n");
+   return -ENODEV;
+   }
+   if (input->nr < 4) {
+   lnb_command(dev, port->lnr, input->nr, LNB_CMD_INIT);
+   lnb_set_voltage(dev, port->lnr, input->nr, SEC_VOLTAGE_OFF);
+   }
+   ddb_lnb_init_fmode(dev, link, fmode);
+
+   dvb->fe->ops.set_voltage = max_set_voltage;
+   dvb->fe->ops.enable_high_lnb_voltage = max_enable_high_lnb_voltage;
+   dvb->fe->ops.set_tone = max_set_tone;
+   dvb->diseqc_send_master_cmd = dvb->fe->ops.diseqc_send_master_cmd;
+   dvb->fe->ops.diseqc_send_master_cmd = max_send_master_cmd;
+   dvb->fe->ops.diseqc_send_burst = max_send_burst;
+   dvb->fe->sec_priv = input;
+   dvb->input = tuner;
+   return 0;
+}
diff --git a/drivers/media/pci/ddbridge/ddbridge-max.h 
b/drivers/media/pci/ddbridge/ddbridge-max.h
index bf8bf38739f6..82efc53baa94 100644
--- a/drivers/media/pci/ddbridge/ddbridge-max.h
+++ b/drivers/media/pci/ddbridge/ddbridge-max.h
@@ -25,5 +25,6 @@
 
 int ddb_lnb_init_fmode(struct ddb *dev, struct ddb_link *link, u32 fm);
 int ddb_fe_attach_mxl5xx(struct ddb_input *input);
+int ddb_fe_attach_mci(struct ddb_input *input);
 
 #endif /* _DDBRIDGE_MAX_H */
-- 
2.16.1



[PATCH 05/20] [media] ddbridge: move ddb_wq and the wq+class initialisation to -core

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Move the ddbridge module initialisation and cleanup code to ddbridge-core
and set up the ddb_wq workqueue there, and create and destroy the ddb
device class there aswell. Due to this, the prototypes for ddb_wq,
ddb_class_create() and ddb_class_destroy() aren't required in ddbridge.h
anymore, so remove them. Also, declare ddb_wq and the ddb_class_*()
functions static.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 32 +++---
 drivers/media/pci/ddbridge/ddbridge-main.c | 21 +++-
 drivers/media/pci/ddbridge/ddbridge.h  |  7 ++-
 3 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 933046d03db5..fb9a2cb758e6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -100,7 +100,7 @@ MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as 
single demods");
 
 static DEFINE_MUTEX(redirect_lock);
 
-struct workqueue_struct *ddb_wq;
+static struct workqueue_struct *ddb_wq;
 
 static struct ddb *ddbs[DDB_MAX_ADAPTER];
 
@@ -3055,7 +3055,7 @@ static struct class ddb_class = {
.devnode= ddb_devnode,
 };
 
-int ddb_class_create(void)
+static int ddb_class_create(void)
 {
ddb_major = register_chrdev(0, DDB_NAME, _fops);
if (ddb_major < 0)
@@ -3065,7 +3065,7 @@ int ddb_class_create(void)
return 0;
 }
 
-void ddb_class_destroy(void)
+static void ddb_class_destroy(void)
 {
class_unregister(_class);
unregister_chrdev(ddb_major, DDB_NAME);
@@ -3337,3 +3337,29 @@ void ddb_unmap(struct ddb *dev)
iounmap(dev->regs);
vfree(dev);
 }
+
+int ddb_exit_ddbridge(int stage, int error)
+{
+   switch (stage) {
+   default:
+   case 2:
+   destroy_workqueue(ddb_wq);
+   /* fall-through */
+   case 1:
+   ddb_class_destroy();
+   break;
+   }
+
+   return error;
+}
+
+int ddb_init_ddbridge(void)
+{
+   if (ddb_class_create() < 0)
+   return -1;
+   ddb_wq = alloc_workqueue("ddbridge", 0, 0);
+   if (!ddb_wq)
+   return ddb_exit_ddbridge(1, -1);
+
+   return 0;
+}
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index bde04dc39080..7088162af9d3 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -282,32 +282,25 @@ static struct pci_driver ddb_pci_driver = {
 
 static __init int module_init_ddbridge(void)
 {
-   int stat = -1;
+   int stat;
 
pr_info("Digital Devices PCIE bridge driver "
DDBRIDGE_VERSION
", Copyright (C) 2010-17 Digital Devices GmbH\n");
-   if (ddb_class_create() < 0)
-   return -1;
-   ddb_wq = create_workqueue("ddbridge");
-   if (!ddb_wq)
-   goto exit1;
+   stat = ddb_init_ddbridge();
+   if (stat < 0)
+   return stat;
stat = pci_register_driver(_pci_driver);
if (stat < 0)
-   goto exit2;
-   return stat;
-exit2:
-   destroy_workqueue(ddb_wq);
-exit1:
-   ddb_class_destroy();
+   ddb_exit_ddbridge(0, stat);
+
return stat;
 }
 
 static __exit void module_exit_ddbridge(void)
 {
pci_unregister_driver(_pci_driver);
-   destroy_workqueue(ddb_wq);
-   ddb_class_destroy();
+   ddb_exit_ddbridge(0, 0);
 }
 
 module_init(module_init_ddbridge);
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index e22e67d7e0fe..dbd5f551ce76 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -368,9 +368,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, 
u32 addr, u32 len);
 
 //
 
-/* ddbridge-main.c (modparams) */
-extern struct workqueue_struct *ddb_wq;
-
 /* ddbridge-core.c */
 void ddb_ports_detach(struct ddb *dev);
 void ddb_ports_release(struct ddb *dev);
@@ -383,9 +380,9 @@ void ddb_ports_init(struct ddb *dev);
 int ddb_buffers_alloc(struct ddb *dev);
 int ddb_ports_attach(struct ddb *dev);
 int ddb_device_create(struct ddb *dev);
-int ddb_class_create(void);
-void ddb_class_destroy(void);
 int ddb_init(struct ddb *dev);
 void ddb_unmap(struct ddb *dev);
+int ddb_exit_ddbridge(int stage, int error);
+int ddb_init_ddbridge(void);
 
 #endif /* DDBRIDGE_H */
-- 
2.16.1



[PATCH 14/20] [media] ddbridge: make DMA buffer count and size modparam-configurable

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Make the number of DMA buffers and their size configurable using module
parameters. Being able to set these to a higher number might help on
busy systems when handling overall high data rates without having to
edit the driver sources and recompile things.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 30 --
 drivers/media/pci/ddbridge/ddbridge.h  | 12 
 2 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index e9c2e3e5d64b..8907551b02e4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -96,6 +96,15 @@ static int stv0910_single;
 module_param(stv0910_single, int, 0444);
 MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
 
+static int dma_buf_num = 8;
+module_param(dma_buf_num, int, 0444);
+MODULE_PARM_DESC(dma_buf_num, "Number of DMA buffers, possible values: 8-32");
+
+static int dma_buf_size = 21;
+module_param(dma_buf_size, int, 0444);
+MODULE_PARM_DESC(dma_buf_size,
+"DMA buffer size as multiple of 128*47, possible values: 
1-43");
+
 //
 
 static DEFINE_MUTEX(redirect_lock);
@@ -2187,16 +2196,16 @@ static void ddb_dma_init(struct ddb_io *io, int nr, int 
out)
INIT_WORK(>work, output_work);
dma->regs = rm->odma->base + rm->odma->size * nr;
dma->bufregs = rm->odma_buf->base + rm->odma_buf->size * nr;
-   dma->num = OUTPUT_DMA_BUFS;
-   dma->size = OUTPUT_DMA_SIZE;
-   dma->div = OUTPUT_DMA_IRQ_DIV;
+   dma->num = dma_buf_num;
+   dma->size = dma_buf_size * 128 * 47;
+   dma->div = 1;
} else {
INIT_WORK(>work, input_work);
dma->regs = rm->idma->base + rm->idma->size * nr;
dma->bufregs = rm->idma_buf->base + rm->idma_buf->size * nr;
-   dma->num = INPUT_DMA_BUFS;
-   dma->size = INPUT_DMA_SIZE;
-   dma->div = INPUT_DMA_IRQ_DIV;
+   dma->num = dma_buf_num;
+   dma->size = dma_buf_size * 128 * 47;
+   dma->div = 1;
}
ddbwritel(io->port->dev, 0, DMA_BUFFER_ACK(dma));
dev_dbg(io->port->dev->dev, "init link %u, io %u, dma %u, dmaregs %08x 
bufregs %08x\n",
@@ -3353,6 +3362,15 @@ int ddb_exit_ddbridge(int stage, int error)
 
 int ddb_init_ddbridge(void)
 {
+   if (dma_buf_num < 8)
+   dma_buf_num = 8;
+   if (dma_buf_num > 32)
+   dma_buf_num = 32;
+   if (dma_buf_size < 1)
+   dma_buf_size = 1;
+   if (dma_buf_size > 43)
+   dma_buf_size = 43;
+
if (ddb_class_create() < 0)
return -1;
ddb_wq = alloc_workqueue("ddbridge", 0, 0);
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index de9ddf1068bf..86db6f19369a 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -136,20 +136,8 @@ struct ddb_info {
const struct ddb_regmap *regmap;
 };
 
-/* DMA_SIZE MUST be smaller than 256k and
- * MUST be divisible by 188 and 128 !!!
- */
-
 #define DMA_MAX_BUFS 32  /* hardware table limit */
 
-#define INPUT_DMA_BUFS 8
-#define INPUT_DMA_SIZE (128 * 47 * 21)
-#define INPUT_DMA_IRQ_DIV 1
-
-#define OUTPUT_DMA_BUFS 8
-#define OUTPUT_DMA_SIZE (128 * 47 * 21)
-#define OUTPUT_DMA_IRQ_DIV 1
-
 struct ddb;
 struct ddb_port;
 
-- 
2.16.1



[PATCH 07/20] [media] ddbridge: request/free_irq using pci_irq_vector, enable MSI-X

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Instead of trying to manage IRQ numbers on itself, utilise the
pci_irq_vector() function to do this, which will take care of correct IRQ
numbering for MSI and non-MSI IRQs. While at it, request and enable MSI-X
interrupts for hardware (boards and cards) that support this.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-main.c | 24 ++--
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 77089081db1f..008be9066814 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -77,8 +77,8 @@ static void ddb_irq_exit(struct ddb *dev)
 {
ddb_irq_disable(dev);
if (dev->msi == 2)
-   free_irq(dev->pdev->irq + 1, dev);
-   free_irq(dev->pdev->irq, dev);
+   free_irq(pci_irq_vector(dev->pdev, 1), dev);
+   free_irq(pci_irq_vector(dev->pdev, 0), dev);
 }
 
 static void ddb_remove(struct pci_dev *pdev)
@@ -105,7 +105,8 @@ static void ddb_irq_msi(struct ddb *dev, int nr)
int stat;
 
if (msi && pci_msi_enabled()) {
-   stat = pci_alloc_irq_vectors(dev->pdev, 1, nr, PCI_IRQ_MSI);
+   stat = pci_alloc_irq_vectors(dev->pdev, 1, nr,
+PCI_IRQ_MSI | PCI_IRQ_MSIX);
if (stat >= 1) {
dev->msi = stat;
dev_info(dev->dev, "using %d MSI interrupt(s)\n",
@@ -137,21 +138,24 @@ static int ddb_irq_init(struct ddb *dev)
if (dev->msi)
irq_flag = 0;
if (dev->msi == 2) {
-   stat = request_irq(dev->pdev->irq, ddb_irq_handler0,
-  irq_flag, "ddbridge", (void *)dev);
+   stat = request_irq(pci_irq_vector(dev->pdev, 0),
+  ddb_irq_handler0, irq_flag, "ddbridge",
+  (void *)dev);
if (stat < 0)
return stat;
-   stat = request_irq(dev->pdev->irq + 1, ddb_irq_handler1,
-  irq_flag, "ddbridge", (void *)dev);
+   stat = request_irq(pci_irq_vector(dev->pdev, 1),
+  ddb_irq_handler1, irq_flag, "ddbridge",
+  (void *)dev);
if (stat < 0) {
-   free_irq(dev->pdev->irq, dev);
+   free_irq(pci_irq_vector(dev->pdev, 0), dev);
return stat;
}
} else
 #endif
{
-   stat = request_irq(dev->pdev->irq, ddb_irq_handler,
-  irq_flag, "ddbridge", (void *)dev);
+   stat = request_irq(pci_irq_vector(dev->pdev, 0),
+  ddb_irq_handler, irq_flag, "ddbridge",
+  (void *)dev);
if (stat < 0)
return stat;
}
-- 
2.16.1



[PATCH 18/20] [media] ddbridge: add hardware defs and PCI IDs for MCI cards

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Add PCI IDs and ddb_info for the new MCI-based MaxSX8 cards. Also add
needed defines so the cards can be hooked up into ddbridge's probe and
attach handling.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-hw.c   | 11 +++
 drivers/media/pci/ddbridge/ddbridge-main.c |  1 +
 drivers/media/pci/ddbridge/ddbridge.h  | 11 +++
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-hw.c 
b/drivers/media/pci/ddbridge/ddbridge-hw.c
index c6d14925e2fc..1d3ee6accdd5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-hw.c
+++ b/drivers/media/pci/ddbridge/ddbridge-hw.c
@@ -311,6 +311,16 @@ static const struct ddb_info ddb_s2_48 = {
.tempmon_irq = 24,
 };
 
+static const struct ddb_info ddb_s2x_48 = {
+   .type = DDB_OCTOPUS_MCI,
+   .name = "Digital Devices MAX SX8",
+   .regmap   = _map,
+   .port_num = 4,
+   .i2c_mask = 0x00,
+   .tempmon_irq = 24,
+   .mci  = 4
+};
+
 //
 //
 //
@@ -346,6 +356,7 @@ static const struct ddb_device_id ddb_device_ids[] = {
DDB_DEVID(0x0008, 0x0036, ddb_isdbt_8),
DDB_DEVID(0x0008, 0x0037, ddb_c2t2i_v0_8),
DDB_DEVID(0x0008, 0x0038, ddb_c2t2i_8),
+   DDB_DEVID(0x0009, 0x0025, ddb_s2x_48),
DDB_DEVID(0x0006, 0x0039, ddb_ctv7),
DDB_DEVID(0x0011, 0x0040, ddb_ci),
DDB_DEVID(0x0011, 0x0041, ddb_cis),
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 6356b48b3874..f4748cfd904b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -264,6 +264,7 @@ static const struct pci_device_id ddb_id_table[] = {
DDB_DEVICE_ANY(0x0006),
DDB_DEVICE_ANY(0x0007),
DDB_DEVICE_ANY(0x0008),
+   DDB_DEVICE_ANY(0x0009),
DDB_DEVICE_ANY(0x0011),
DDB_DEVICE_ANY(0x0012),
DDB_DEVICE_ANY(0x0013),
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index cb69021a3443..72fe33cb72b9 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -112,11 +112,12 @@ struct ddb_ids {
 
 struct ddb_info {
int   type;
-#define DDB_NONE 0
-#define DDB_OCTOPUS  1
-#define DDB_OCTOPUS_CI   2
-#define DDB_OCTOPUS_MAX  5
+#define DDB_NONE0
+#define DDB_OCTOPUS 1
+#define DDB_OCTOPUS_CI  2
+#define DDB_OCTOPUS_MAX 5
 #define DDB_OCTOPUS_MAX_CT  6
+#define DDB_OCTOPUS_MCI 9
char *name;
u32   i2c_mask;
u8port_num;
@@ -133,6 +134,7 @@ struct ddb_info {
 #define TS_QUIRK_REVERSED 2
 #define TS_QUIRK_ALT_OSC  8
u32   tempmon_irq;
+   u8mci;
const struct ddb_regmap *regmap;
 };
 
@@ -253,6 +255,7 @@ struct ddb_port {
 #define DDB_CI_EXTERNAL_XO2_B13
 #define DDB_TUNER_DVBS_STV0910_PR 14
 #define DDB_TUNER_DVBC2T2I_SONY_P 15
+#define DDB_TUNER_MCI16
 
 #define DDB_TUNER_XO232
 #define DDB_TUNER_DVBS_STV0910   (DDB_TUNER_XO2 + 0)
-- 
2.16.1



[PATCH 09/20] [media] ddbridge: add macros to handle IRQs in nibble and byte blocks

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Currently, each IRQ requires one IRQ_HANDLE() line to call each IRQ
handler that was set up. Add a IRQ_HANDLE_NIBBLE() and IRQ_HANDLE_BYTE()
macro to call all handlers in blocks of four (_NIBBLE) or eight (_BYTE)
handlers at a time, to make this construct more compact.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 67 --
 1 file changed, 27 insertions(+), 40 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index be6935bd0cb5..5fbb0996a12c 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2403,54 +2403,41 @@ void ddb_ports_release(struct ddb *dev)
dev->link[0].irq[_nr].handler(dev->link[0].irq[_nr].data); } \
while (0)
 
+#define IRQ_HANDLE_NIBBLE(_shift) { \
+   if (s & (0x000f << ((_shift) & 0x1f))) { \
+   IRQ_HANDLE(0 + (_shift));\
+   IRQ_HANDLE(1 + (_shift));\
+   IRQ_HANDLE(2 + (_shift));\
+   IRQ_HANDLE(3 + (_shift));\
+   }\
+}
+
+#define IRQ_HANDLE_BYTE(_shift) {   \
+   if (s & (0x00ff << ((_shift) & 0x1f))) { \
+   IRQ_HANDLE(0 + (_shift));\
+   IRQ_HANDLE(1 + (_shift));\
+   IRQ_HANDLE(2 + (_shift));\
+   IRQ_HANDLE(3 + (_shift));\
+   IRQ_HANDLE(4 + (_shift));\
+   IRQ_HANDLE(5 + (_shift));\
+   IRQ_HANDLE(6 + (_shift));\
+   IRQ_HANDLE(7 + (_shift));\
+   }\
+}
+
 static void irq_handle_msg(struct ddb *dev, u32 s)
 {
dev->i2c_irq++;
-   IRQ_HANDLE(0);
-   IRQ_HANDLE(1);
-   IRQ_HANDLE(2);
-   IRQ_HANDLE(3);
+   IRQ_HANDLE_NIBBLE(0);
 }
 
 static void irq_handle_io(struct ddb *dev, u32 s)
 {
dev->ts_irq++;
-   if ((s & 0x00f0)) {
-   IRQ_HANDLE(4);
-   IRQ_HANDLE(5);
-   IRQ_HANDLE(6);
-   IRQ_HANDLE(7);
-   }
-   if ((s & 0xff00)) {
-   IRQ_HANDLE(8);
-   IRQ_HANDLE(9);
-   IRQ_HANDLE(10);
-   IRQ_HANDLE(11);
-   IRQ_HANDLE(12);
-   IRQ_HANDLE(13);
-   IRQ_HANDLE(14);
-   IRQ_HANDLE(15);
-   }
-   if ((s & 0x00ff)) {
-   IRQ_HANDLE(16);
-   IRQ_HANDLE(17);
-   IRQ_HANDLE(18);
-   IRQ_HANDLE(19);
-   IRQ_HANDLE(20);
-   IRQ_HANDLE(21);
-   IRQ_HANDLE(22);
-   IRQ_HANDLE(23);
-   }
-   if ((s & 0xff00)) {
-   IRQ_HANDLE(24);
-   IRQ_HANDLE(25);
-   IRQ_HANDLE(26);
-   IRQ_HANDLE(27);
-   IRQ_HANDLE(28);
-   IRQ_HANDLE(29);
-   IRQ_HANDLE(30);
-   IRQ_HANDLE(31);
-   }
+   IRQ_HANDLE_NIBBLE(4);
+   IRQ_HANDLE_BYTE(8);
+   IRQ_HANDLE_BYTE(16);
+   IRQ_HANDLE_BYTE(24);
 }
 
 irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
-- 
2.16.1



[PATCH 12/20] [media] ddbridge: fix output buffer check

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

A 188 byte gap has to be left between the writer and the consumer. This
requires 2*188 bytes available to be able to write to the output buffers.
So, change ddb_output_free() to report free bytes according to this rule.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index c22537eceee5..e9c2e3e5d64b 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -587,12 +587,12 @@ static u32 ddb_output_free(struct ddb_output *output)
 
if (output->dma->cbuf != idx) {
if output->dma->cbuf + 1) % output->dma->num) == idx) &&
-   (output->dma->size - output->dma->coff <= 188))
+   (output->dma->size - output->dma->coff <= (2 * 188)))
return 0;
return 188;
}
diff = off - output->dma->coff;
-   if (diff <= 0 || diff > 188)
+   if (diff <= 0 || diff > (2 * 188))
return 188;
return 0;
 }
-- 
2.16.1



[PATCH 03/20] [media] dvb-frontends/stv0910: fix CNR reporting in read_snr()

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The CNR value determined in read_snr() is reported via the wrong variable.
It uses FE_SCALE_DECIBEL, which implies the value to be reported in svalue
instead of uvalue. Fix this accordingly.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/dvb-frontends/stv0910.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index 0d6130f97c36..e3d939933d6e 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1324,7 +1324,7 @@ static int read_snr(struct dvb_frontend *fe)
 
if (!get_signal_to_noise(state, )) {
p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
-   p->cnr.stat[0].uvalue = 100 * snrval; /* fix scale */
+   p->cnr.stat[0].svalue = 100 * snrval; /* fix scale */
} else {
p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
-- 
2.16.1



[PATCH 10/20] [media] ddbridge: improve separated MSI IRQ handling

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Improve IRQ handling in the separated MSG/I2C and IO/TSDATA handlers by
applying a mask for recognized bits immediately upon reading the IRQ mask
from the hardware, so only the bits/IRQs that actually were set will be
acked.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 5fbb0996a12c..9d91221dacc4 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -2443,16 +2443,17 @@ static void irq_handle_io(struct ddb *dev, u32 s)
 irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
 {
struct ddb *dev = (struct ddb *)dev_id;
-   u32 s = ddbreadl(dev, INTERRUPT_STATUS);
+   u32 mask = 0x8f00;
+   u32 s = mask & ddbreadl(dev, INTERRUPT_STATUS);
 
+   if (!s)
+   return IRQ_NONE;
do {
if (s & 0x8000)
return IRQ_NONE;
-   if (!(s & 0xf00))
-   return IRQ_NONE;
-   ddbwritel(dev, s & 0xf00, INTERRUPT_ACK);
+   ddbwritel(dev, s, INTERRUPT_ACK);
irq_handle_io(dev, s);
-   } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
+   } while ((s = mask & ddbreadl(dev, INTERRUPT_STATUS)));
 
return IRQ_HANDLED;
 }
@@ -2460,16 +2461,17 @@ irqreturn_t ddb_irq_handler0(int irq, void *dev_id)
 irqreturn_t ddb_irq_handler1(int irq, void *dev_id)
 {
struct ddb *dev = (struct ddb *)dev_id;
-   u32 s = ddbreadl(dev, INTERRUPT_STATUS);
+   u32 mask = 0x800f;
+   u32 s = mask & ddbreadl(dev, INTERRUPT_STATUS);
 
+   if (!s)
+   return IRQ_NONE;
do {
if (s & 0x8000)
return IRQ_NONE;
-   if (!(s & 0xf))
-   return IRQ_NONE;
-   ddbwritel(dev, s & 0xf, INTERRUPT_ACK);
+   ddbwritel(dev, s, INTERRUPT_ACK);
irq_handle_msg(dev, s);
-   } while ((s = ddbreadl(dev, INTERRUPT_STATUS)));
+   } while ((s = mask & ddbreadl(dev, INTERRUPT_STATUS)));
 
return IRQ_HANDLED;
 }
-- 
2.16.1



[PATCH 06/20] [media] ddbridge: move MSI IRQ cleanup to a helper function

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Introduce the ddb_msi_exit() helper to be used for cleaning up previously
allocated MSI IRQ vectors. Deduplicates code and makes things look
cleaner as for all cleanup work the CONFIG_PCI_MSI ifdeffery is only
needed in the helper now. Also, replace the call to the deprecated
pci_disable_msi() function with pci_free_irq_vectors().

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-main.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 7088162af9d3..77089081db1f 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -65,16 +65,20 @@ static void ddb_irq_disable(struct ddb *dev)
ddbwritel(dev, 0, MSI1_ENABLE);
 }
 
+static void ddb_msi_exit(struct ddb *dev)
+{
+#ifdef CONFIG_PCI_MSI
+   if (dev->msi)
+   pci_free_irq_vectors(dev->pdev);
+#endif
+}
+
 static void ddb_irq_exit(struct ddb *dev)
 {
ddb_irq_disable(dev);
if (dev->msi == 2)
free_irq(dev->pdev->irq + 1, dev);
free_irq(dev->pdev->irq, dev);
-#ifdef CONFIG_PCI_MSI
-   if (dev->msi)
-   pci_disable_msi(dev->pdev);
-#endif
 }
 
 static void ddb_remove(struct pci_dev *pdev)
@@ -86,6 +90,7 @@ static void ddb_remove(struct pci_dev *pdev)
ddb_i2c_release(dev);
 
ddb_irq_exit(dev);
+   ddb_msi_exit(dev);
ddb_ports_release(dev);
ddb_buffers_free(dev);
 
@@ -230,8 +235,7 @@ static int ddb_probe(struct pci_dev *pdev,
ddb_irq_exit(dev);
 fail0:
dev_err(>dev, "fail0\n");
-   if (dev->msi)
-   pci_disable_msi(dev->pdev);
+   ddb_msi_exit(dev);
 fail:
dev_err(>dev, "fail\n");
 
-- 
2.16.1



[PATCH 16/20] [media] ddbridge: initial support for MCI-based MaxSX8 cards

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

This adds initial support for the new MCI-based (micro-code interface)
DD cards, with the first one being the MaxSX8 eight-tuner DVB-S/S2/S2X
PCIe card. The MCI is basically a generalized interface implemented in
the card's FPGA firmware and usable for all kind of cards, without the
need to implement any demod/tuner drivers as this interface "hides" any
I2C interface to the actual ICs, in other words any required driver is
implemented in the card firmware.

At this stage, the MCI interface is quite rudimentary with things like
signal statistics reporting missing, but is already working to serve
DVB streams to DVB applications. Missing functionality will be enabled
over time.

This implements only the ddbridge-mci sub-object and hooks it up to the
Makefile so the object gets build. The upcoming commits hook this module
into all other ddbridge parts where required, including device IDs etc.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/Makefile   |   2 +-
 drivers/media/pci/ddbridge/ddbridge-mci.c | 550 ++
 drivers/media/pci/ddbridge/ddbridge-mci.h | 152 +
 3 files changed, 703 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.c
 create mode 100644 drivers/media/pci/ddbridge/ddbridge-mci.h

diff --git a/drivers/media/pci/ddbridge/Makefile 
b/drivers/media/pci/ddbridge/Makefile
index 745b37d07558..9b9e35f171b7 100644
--- a/drivers/media/pci/ddbridge/Makefile
+++ b/drivers/media/pci/ddbridge/Makefile
@@ -4,7 +4,7 @@
 #
 
 ddbridge-objs := ddbridge-main.o ddbridge-core.o ddbridge-ci.o \
-   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o
+   ddbridge-hw.o ddbridge-i2c.o ddbridge-max.o ddbridge-mci.o
 
 obj-$(CONFIG_DVB_DDBRIDGE) += ddbridge.o
 
diff --git a/drivers/media/pci/ddbridge/ddbridge-mci.c 
b/drivers/media/pci/ddbridge/ddbridge-mci.c
new file mode 100644
index ..214b301f30a5
--- /dev/null
+++ b/drivers/media/pci/ddbridge/ddbridge-mci.c
@@ -0,0 +1,550 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ddbridge-mci.c: Digital Devices microcode interface
+ *
+ * Copyright (C) 2017 Digital Devices GmbH
+ *Ralph Metzler <r...@metzlerbros.de>
+ *Marcus Metzler <m...@metzlerbros.de>
+ *
+ * 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 "ddbridge.h"
+#include "ddbridge-io.h"
+#include "ddbridge-mci.h"
+
+static LIST_HEAD(mci_list);
+
+static const u32 MCLK = (155000 / 12);
+static const u32 MAX_DEMOD_LDPC_BITRATE = (155000 / 6);
+static const u32 MAX_LDPC_BITRATE = (72000);
+
+struct mci_base {
+   struct list_head mci_list;
+   void*key;
+   struct ddb_link *link;
+   struct completioncompletion;
+
+   struct device   *dev;
+   struct mutex tuner_lock; /* concurrent tuner access lock */
+   u8   adr;
+   struct mutex mci_lock; /* concurrent MCI access lock */
+   int  count;
+
+   u8   tuner_use_count[4];
+   u8   assigned_demod[8];
+   u32  used_ldpc_bitrate[8];
+   u8   demod_in_use[8];
+   u32  iq_mode;
+};
+
+struct mci {
+   struct mci_base *base;
+   struct dvb_frontend  fe;
+   int  nr;
+   int  demod;
+   int  tuner;
+   int  first_time_lock;
+   int  started;
+   struct mci_resultsignal_info;
+
+   u32  bb_mode;
+};
+
+static int mci_reset(struct mci *state)
+{
+   struct ddb_link *link = state->base->link;
+   u32 status = 0;
+   u32 timeout = 40;
+
+   ddblwritel(link, MCI_CONTROL_RESET, MCI_CONTROL);
+   ddblwritel(link, 0, MCI_CONTROL + 4); /* 1= no internal init */
+   msleep(300);
+   ddblwritel(link, 0, MCI_CONTROL);
+
+   while (1) {
+   status = ddblreadl(link, MCI_CONTROL);
+   if ((status & MCI_CONTROL_READY) == MCI_CONTROL_READY)
+   break;
+   if (--timeout == 0)
+   break;
+   msleep(50);
+   }
+   if ((status & MCI_CONTROL_READY) == 0)
+   return -1;
+   if (link->ids.device == 0x0009)
+   ddblwritel(

[PATCH 20/20] [media] ddbridge: set driver version to 0.9.33-integrated

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Set DDBRIDGE_VERSION in ddbridge.h to 0.9.33-integrated to reflect the
updated driver.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 72fe33cb72b9..a66b1125cc74 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -63,7 +63,7 @@
 #include 
 #include 
 
-#define DDBRIDGE_VERSION "0.9.32-integrated"
+#define DDBRIDGE_VERSION "0.9.33-integrated"
 
 #define DDB_MAX_I2C32
 #define DDB_MAX_PORT   32
-- 
2.16.1



[PATCH 19/20] [media] ddbridge: recognize and attach the MaxSX8 cards

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Add needed logic into dvb_input_attach(), ddb_port_probe() and
ddb_ports_init() to initialize and support these new cards.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 59e137516003..4a2819d3e225 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1574,6 +1574,10 @@ static int dvb_input_attach(struct ddb_input *input)
if (demod_attach_dummy(input) < 0)
goto err_detach;
break;
+   case DDB_TUNER_MCI:
+   if (ddb_fe_attach_mci(input) < 0)
+   goto err_detach;
+   break;
default:
return 0;
}
@@ -1869,6 +1873,16 @@ static void ddb_port_probe(struct ddb_port *port)
return;
}
 
+   if (dev->link[l].info->type == DDB_OCTOPUS_MCI) {
+   if (port->nr >= dev->link[l].info->mci)
+   return;
+   port->name = "DUAL MCI";
+   port->type_name = "MCI";
+   port->class = DDB_PORT_TUNER;
+   port->type = DDB_TUNER_MCI;
+   return;
+   }
+
if (port->nr > 1 && dev->link[l].info->type == DDB_OCTOPUS_CI) {
port->name = "CI internal";
port->type_name = "INTERNAL";
@@ -2411,6 +2425,7 @@ void ddb_ports_init(struct ddb *dev)
break;
case DDB_OCTOPUS_MAX:
case DDB_OCTOPUS_MAX_CT:
+   case DDB_OCTOPUS_MCI:
ddb_input_init(port, 2 * i, 0, 2 * p);
ddb_input_init(port, 2 * i + 1, 1, 2 * p + 1);
break;
-- 
2.16.1



[PATCH 02/20] [media] dvb-frontends/stv0910: increase parallel TS output speed

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

When running in parallel TS mode (cfg->parallel=1), increase the output
speed in the demod.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/dvb-frontends/stv0910.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv0910.c 
b/drivers/media/dvb-frontends/stv0910.c
index f5b5ce971c0c..0d6130f97c36 100644
--- a/drivers/media/dvb-frontends/stv0910.c
+++ b/drivers/media/dvb-frontends/stv0910.c
@@ -1200,7 +1200,6 @@ static int probe(struct stv *state)
write_reg(state, RSTV0910_P1_TSCFGM, 0xC0); /* Manual speed */
write_reg(state, RSTV0910_P1_TSCFGL, 0x20);
 
-   /* Speed = 67.5 MHz */
write_reg(state, RSTV0910_P1_TSSPEED, state->tsspeed);
 
write_reg(state, RSTV0910_P2_TSCFGH, state->tscfgh | 0x01);
@@ -1208,7 +1207,6 @@ static int probe(struct stv *state)
write_reg(state, RSTV0910_P2_TSCFGM, 0xC0); /* Manual speed */
write_reg(state, RSTV0910_P2_TSCFGL, 0x20);
 
-   /* Speed = 67.5 MHz */
write_reg(state, RSTV0910_P2_TSSPEED, state->tsspeed);
 
/* Reset stream merger */
@@ -1790,7 +1788,7 @@ struct dvb_frontend *stv0910_attach(struct i2c_adapter 
*i2c,
state->tscfgh = 0x20 | (cfg->parallel ? 0 : 0x40);
state->tsgeneral = (cfg->parallel == 2) ? 0x02 : 0x00;
state->i2crpt = 0x0A | ((cfg->rptlvl & 0x07) << 4);
-   state->tsspeed = 0x28;
+   state->tsspeed = cfg->parallel ? 0x10 : 0x28;
state->nr = nr;
state->regoff = state->nr ? 0 : 0x200;
state->search_range = 1600;
-- 
2.16.1



[PATCH 04/20] [media] ddbridge: move modparams to ddbridge-core.c

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

Besides the 'msi' module option, all options are used from within
ddbridge-core only, so move them over from ddbridge-main, and declare the
associated variables static. Since the prototypes in ddbridge.h aren't
necessary anymore now, remove them. As a side effect, this has the benefit
of aligning things more with the dddvb upstream.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/ddbridge-core.c | 28 
 drivers/media/pci/ddbridge/ddbridge-main.c | 28 
 drivers/media/pci/ddbridge/ddbridge.h  |  6 --
 3 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 90687eff5909..933046d03db5 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -68,6 +68,34 @@ module_param(adapter_alloc, int, 0444);
 MODULE_PARM_DESC(adapter_alloc,
 "0-one adapter per io, 1-one per tab with io, 2-one per tab, 
3-one for all");
 
+static int ci_bitrate = 7;
+module_param(ci_bitrate, int, 0444);
+MODULE_PARM_DESC(ci_bitrate, " Bitrate in KHz for output to CI.");
+
+static int ts_loop = -1;
+module_param(ts_loop, int, 0444);
+MODULE_PARM_DESC(ts_loop, "TS in/out test loop on port ts_loop");
+
+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");
+
+#ifdef __arm__
+static int alt_dma = 1;
+#else
+static int alt_dma;
+#endif
+module_param(alt_dma, int, 0444);
+MODULE_PARM_DESC(alt_dma, "use alternative DMA buffer handling");
+
+static int no_init;
+module_param(no_init, int, 0444);
+MODULE_PARM_DESC(no_init, "do not initialize most devices");
+
+static int stv0910_single;
+module_param(stv0910_single, int, 0444);
+MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
+
 //
 
 static DEFINE_MUTEX(redirect_lock);
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c 
b/drivers/media/pci/ddbridge/ddbridge-main.c
index 26497d6b1395..bde04dc39080 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -55,34 +55,6 @@ MODULE_PARM_DESC(msi, "Control MSI interrupts: 0-disable 
(default), 1-enable");
 #endif
 #endif
 
-int ci_bitrate = 7;
-module_param(ci_bitrate, int, 0444);
-MODULE_PARM_DESC(ci_bitrate, " Bitrate in KHz for output to CI.");
-
-int ts_loop = -1;
-module_param(ts_loop, int, 0444);
-MODULE_PARM_DESC(ts_loop, "TS in/out test loop on port ts_loop");
-
-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");
-
-#ifdef __arm__
-int alt_dma = 1;
-#else
-int alt_dma;
-#endif
-module_param(alt_dma, int, 0444);
-MODULE_PARM_DESC(alt_dma, "use alternative DMA buffer handling");
-
-int no_init;
-module_param(no_init, int, 0444);
-MODULE_PARM_DESC(no_init, "do not initialize most devices");
-
-int stv0910_single;
-module_param(stv0910_single, int, 0444);
-MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
-
 //
 //
 //
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index f223dc6c9963..e22e67d7e0fe 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -369,12 +369,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, 
u32 addr, u32 len);
 //
 
 /* ddbridge-main.c (modparams) */
-extern int ci_bitrate;
-extern int ts_loop;
-extern int xo2_speed;
-extern int alt_dma;
-extern int no_init;
-extern int stv0910_single;
 extern struct workqueue_struct *ddb_wq;
 
 /* ddbridge-core.c */
-- 
2.16.1



[PATCH 15/20] [media] ddbridge: support dummy tuners with 125MByte/s dummy data stream

2018-04-02 Thread Daniel Scheller
From: Daniel Scheller <d.schel...@gmx.net>

The Octopus V3 and Octopus Mini devices support set up of a dummy tuner
mode on port 0 that will deliver a continuous data stream of 125MBytes
per second while raising IRQs and filling the DMA buffers, which comes
handy for some stress, PCIe link and IRQ handling testing. The dummy
frontend is registered using dvb_dummy_fe's QAM dummy frontend. Set
ddbridge.dummy_tuner to 1 to enable this on the supported cards.

Picked up from the upstream dddvb-0.9.33 release.

Signed-off-by: Daniel Scheller <d.schel...@gmx.net>
---
 drivers/media/pci/ddbridge/Kconfig |  1 +
 drivers/media/pci/ddbridge/ddbridge-core.c | 36 ++
 drivers/media/pci/ddbridge/ddbridge.h  |  1 +
 3 files changed, 38 insertions(+)

diff --git a/drivers/media/pci/ddbridge/Kconfig 
b/drivers/media/pci/ddbridge/Kconfig
index a422dde2f34a..16faef265e97 100644
--- a/drivers/media/pci/ddbridge/Kconfig
+++ b/drivers/media/pci/ddbridge/Kconfig
@@ -14,6 +14,7 @@ config DVB_DDBRIDGE
select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
select DVB_MXL5XX if MEDIA_SUBDRV_AUTOSELECT
select DVB_CXD2099 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_DUMMY_FE if MEDIA_SUBDRV_AUTOSELECT
---help---
  Support for cards with the Digital Devices PCI express bridge:
  - Octopus PCIe Bridge
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c 
b/drivers/media/pci/ddbridge/ddbridge-core.c
index 8907551b02e4..59e137516003 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -54,6 +54,7 @@
 #include "stv6111.h"
 #include "lnbh25.h"
 #include "cxd2099.h"
+#include "dvb_dummy_fe.h"
 
 //
 
@@ -105,6 +106,11 @@ module_param(dma_buf_size, int, 0444);
 MODULE_PARM_DESC(dma_buf_size,
 "DMA buffer size as multiple of 128*47, possible values: 
1-43");
 
+static int dummy_tuner;
+module_param(dummy_tuner, int, 0444);
+MODULE_PARM_DESC(dummy_tuner,
+"attach dummy tuner to port 0 on Octopus V3 or Octopus Mini 
cards");
+
 //
 
 static DEFINE_MUTEX(redirect_lock);
@@ -548,6 +554,9 @@ static void ddb_input_start(struct ddb_input *input)
 
ddbwritel(dev, 0x09, TS_CONTROL(input));
 
+   if (input->port->type == DDB_TUNER_DUMMY)
+   ddbwritel(dev, 0x000fff01, TS_CONTROL2(input));
+
if (input->dma) {
input->dma->running = 1;
spin_unlock_irq(>dma->lock);
@@ -1255,6 +1264,20 @@ static int tuner_attach_stv6111(struct ddb_input *input, 
int type)
return 0;
 }
 
+static int demod_attach_dummy(struct ddb_input *input)
+{
+   struct ddb_dvb *dvb = >port->dvb[input->nr & 1];
+   struct device *dev = input->port->dev->dev;
+
+   dvb->fe = dvb_attach(dvb_dummy_fe_qam_attach);
+   if (!dvb->fe) {
+   dev_err(dev, "QAM dummy attach failed!\n");
+   return -ENODEV;
+   }
+
+   return 0;
+}
+
 static int start_feed(struct dvb_demux_feed *dvbdmxfeed)
 {
struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
@@ -1547,6 +1570,10 @@ static int dvb_input_attach(struct ddb_input *input)
if (tuner_attach_tda18212(input, port->type) < 0)
goto err_tuner;
break;
+   case DDB_TUNER_DUMMY:
+   if (demod_attach_dummy(input) < 0)
+   goto err_detach;
+   break;
default:
return 0;
}
@@ -1809,6 +1836,15 @@ static void ddb_port_probe(struct ddb_port *port)
 
/* Handle missing ports and ports without I2C */
 
+   if (dummy_tuner && !port->nr &&
+   dev->link[0].ids.device == 0x0005) {
+   port->name = "DUMMY";
+   port->class = DDB_PORT_TUNER;
+   port->type = DDB_TUNER_DUMMY;
+   port->type_name = "DUMMY";
+   return;
+   }
+
if (port->nr == ts_loop) {
port->name = "TS LOOP";
port->class = DDB_PORT_LOOP;
diff --git a/drivers/media/pci/ddbridge/ddbridge.h 
b/drivers/media/pci/ddbridge/ddbridge.h
index 86db6f19369a..cb69021a3443 100644
--- a/drivers/media/pci/ddbridge/ddbridge.h
+++ b/drivers/media/pci/ddbridge/ddbridge.h
@@ -236,6 +236,7 @@ struct ddb_port {
char   *name;
char   *type_name;
u32 type;
+#define DDB_TUNER_DUMMY  0x
 #define DDB_TUNER_NONE   0
 #define DDB_TUNER_DVBS_ST1
 #define DDB_TUNER_DVBS_ST_AA 2
-- 
2.16.1



Re: [PATCH 0/5] SPDX license identifiers in all DD drivers

2018-03-21 Thread Daniel Scheller
Hi Greg,

Am Wed, 21 Mar 2018 10:49:32 +0100
schrieb Greg KH <gre...@linuxfoundation.org>:

> On Tue, Mar 20, 2018 at 10:01:27PM +0100, Daniel Scheller wrote:
> > From: Daniel Scheller <d.schel...@gmx.net>
> > 
> > This series adds SPDX license identifiers to all source files which are
> > copyright by either Digital Devices GmbH or Metzlerbros GbR, who are
> > the original authors of the ddbridge, ngene, cxd2099, mxl5xx, stv0910
> > and stv6111 bridge/demod/tuner drivers, with the mxl5xx driver being
> > based on source code released by MaxLinear.
> > [...]
> > The original intention was to fully replace all the licensing headers
> > with only the SPDX License Identifiers as it is done in a lot of other
> > in-tree drivers nowadays. However, Digital Devices disagreed to do this
> > and expressed major concerns regarding this, in that a machine readable
> > license tag instead of a full license boilerplate won't hold up equally,
> > so we agreed to keep the license boilerplate text as is right now.  
> 
> That's really odd, who at that company can I talk to about this?  Or
> really, what lawyer at that company can I point my lawyer at to talk
> about this, that's the only way this is going to get resolved.

I'm not entirely sure, but I guess for a first start it's best to
contact Ralph (from Metzlerbros) and Manfred (from Digital
Devices), being the authors and copyright owners of the DDDVB driver
package where the drivers originate from and thus is the upstream for
the mainlined copies of the mentioned drivers. Both are in the Cc list
(rjkm and mvoelkel) of this thread.

> If it helps, _ALL_ of the major companies that are kernel developers are
> onboard with the removal of the crazy boiler-plate text, so this tiny
> holdout should be easy to resolve.
> 
> > Greg, I'm Cc'ing you on this due to the last paragraph, as AFAIK you're
> > one of the initiators of the SPDX tagging initiative, and you even added
> > tags to 10k+ files all over the tree :-) so we maybe can discuss this
> > further, also with DD, in the hopes you're fine with this - sorry in
> > advance if not.  
> 
> See my review of your first patch here, this needs to be done a lot
> differently...

Check. Thanks for reviewing. The intent was to do a full cleanup of all
licensing things in one go, per driver. Will do one patch for SPDX and
eventual boilerplate cleanup for all drivers, one for MODULE_LICENSE
and one for missing headers in the next iteration. Though I'd wait
with that for now if you like to contact Ralph and Manfred, and do a v2
based on the outcome.

Thanks & best regards,
Daniel Scheller
-- 
https://github.com/herrnst


  1   2   3   4   5   6   >