All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init
@ 2014-08-11 19:58 Olli Salonen
  2014-08-11 19:58 ` [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e Olli Salonen
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Olli Salonen @ 2014-08-11 19:58 UTC (permalink / raw)
  To: olli; +Cc: Olli Salonen, Linux Media Mailing List

Luis Alves submitted a TS mode patch to si2168 earlier, but the patch was rejected due to a small issue. Here is a working version. Also, setting of TS mode is moved from si2168_set_frontend to si2168_init.

This patch adds the TS mode as a config option for the si2168 demod:
- ts_mode added to config struct.
- Possible (interesting) values are
   * Parallel mode = 0x06
   * Serial mode = 0x03

Currently the modules using this demod only use parallel mode. Patches for these modules later in this patch series.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/dvb-frontends/si2168.c      | 17 ++++++++++-------
 drivers/media/dvb-frontends/si2168.h      |  6 ++++++
 drivers/media/dvb-frontends/si2168_priv.h |  1 +
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
index 8f81d97..0eb0e4e 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -297,13 +297,6 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
 	if (ret)
 		goto err;
 
-	memcpy(cmd.args, "\x14\x00\x01\x10\x16\x00", 6);
-	cmd.wlen = 6;
-	cmd.rlen = 4;
-	ret = si2168_cmd_execute(s, &cmd);
-	if (ret)
-		goto err;
-
 	memcpy(cmd.args, "\x14\x00\x09\x10\xe3\x18", 6);
 	cmd.wlen = 6;
 	cmd.rlen = 4;
@@ -465,6 +458,15 @@ static int si2168_init(struct dvb_frontend *fe)
 	dev_info(&s->client->dev, "%s: found a '%s' in warm state\n",
 			KBUILD_MODNAME, si2168_ops.info.name);
 
+	/* set ts mode */
+	memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
+	cmd.args[4] |= s->ts_mode;
+	cmd.wlen = 6;
+	cmd.rlen = 4;
+	ret = si2168_cmd_execute(s, &cmd);
+	if (ret)
+		goto err;
+
 	s->active = true;
 
 	return 0;
@@ -633,6 +635,7 @@ static int si2168_probe(struct i2c_client *client,
 
 	*config->i2c_adapter = s->adapter;
 	*config->fe = &s->fe;
+	s->ts_mode = config->ts_mode;
 
 	i2c_set_clientdata(client, s);
 
diff --git a/drivers/media/dvb-frontends/si2168.h b/drivers/media/dvb-frontends/si2168.h
index 3c5b5ab..e086d67 100644
--- a/drivers/media/dvb-frontends/si2168.h
+++ b/drivers/media/dvb-frontends/si2168.h
@@ -34,6 +34,12 @@ struct si2168_config {
 	 * returned by driver
 	 */
 	struct i2c_adapter **i2c_adapter;
+
+	/* TS mode */
+	u8 ts_mode;
 };
 
+#define SI2168_TS_PARALLEL	0x06
+#define SI2168_TS_SERIAL	0x03
+
 #endif
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h
index ebbf502..0f83284 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -36,6 +36,7 @@ struct si2168 {
 	fe_delivery_system_t delivery_system;
 	fe_status_t fe_status;
 	bool active;
+	u8 ts_mode;
 };
 
 /* firmare command struct */
-- 
1.9.1


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

* [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e
  2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
@ 2014-08-11 19:58 ` Olli Salonen
  2014-08-12 23:23   ` Antti Palosaari
  2014-08-11 19:58 ` [PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400 Olli Salonen
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Olli Salonen @ 2014-08-11 19:58 UTC (permalink / raw)
  To: olli; +Cc: Olli Salonen, Linux Media Mailing List

TS mode must be set in the existing PCTV 461e driver.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/usb/em28xx/em28xx-dvb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index d8e9760..0645793 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1535,6 +1535,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
 			/* attach demod */
 			si2168_config.i2c_adapter = &adapter;
 			si2168_config.fe = &dvb->fe[0];
+			si2168_config.ts_mode = SI2168_TS_PARALLEL;
 			memset(&info, 0, sizeof(struct i2c_board_info));
 			strlcpy(info.type, "si2168", I2C_NAME_SIZE);
 			info.addr = 0x64;
-- 
1.9.1


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

* [PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400
  2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
  2014-08-11 19:58 ` [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e Olli Salonen
@ 2014-08-11 19:58 ` Olli Salonen
  2014-08-12 23:25   ` Antti Palosaari
  2014-08-11 19:58 ` [PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state Olli Salonen
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Olli Salonen @ 2014-08-11 19:58 UTC (permalink / raw)
  To: olli; +Cc: Olli Salonen, Linux Media Mailing List

TS mode must be set in the existing TechnoTrend CT2-4400 driver.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/usb/dvb-usb/cxusb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
index 16bc579..87842e9 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1369,6 +1369,7 @@ static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
 	/* attach frontend */
 	si2168_config.i2c_adapter = &adapter;
 	si2168_config.fe = &adap->fe_adap[0].fe;
+	si2168_config.ts_mode = SI2168_TS_PARALLEL;
 	memset(&info, 0, sizeof(struct i2c_board_info));
 	strlcpy(info.type, "si2168", I2C_NAME_SIZE);
 	info.addr = 0x64;
-- 
1.9.1


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

* [PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state
  2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
  2014-08-11 19:58 ` [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e Olli Salonen
  2014-08-11 19:58 ` [PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400 Olli Salonen
@ 2014-08-11 19:58 ` Olli Salonen
  2014-08-12 23:27   ` Antti Palosaari
  2014-08-11 19:58 ` [PATCH 5/6] cx23855: add frontend set voltage function into state Olli Salonen
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Olli Salonen @ 2014-08-11 19:58 UTC (permalink / raw)
  To: olli; +Cc: Olli Salonen, Linux Media Mailing List

Prepare cx23885 driver for handling I2C client that is needed for certain demodulators and tuners (for example Si2168 and Si2157). I2C client for tuner and demod stored in state and unregistering of the I2C devices added into dvb_unregister.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 16 ++++++++++++++++
 drivers/media/pci/cx23885/cx23885.h     |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 968fecc..2608155 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1643,6 +1643,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
 int cx23885_dvb_unregister(struct cx23885_tsport *port)
 {
 	struct videobuf_dvb_frontend *fe0;
+	struct i2c_client *client;
 
 	/* FIXME: in an error condition where the we have
 	 * an expected number of frontends (attach problem)
@@ -1651,6 +1652,21 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
 	 * This comment only applies to future boards IF they
 	 * implement MFE support.
 	 */
+
+	/* remove I2C client for tuner */
+	client = port->i2c_client_tuner;
+	if (client) {
+		module_put(client->dev.driver->owner);
+		i2c_unregister_device(client);
+	}
+
+	/* remove I2C client for demodulator */
+	client = port->i2c_client_demod;
+	if (client) {
+		module_put(client->dev.driver->owner);
+		i2c_unregister_device(client);
+	}
+
 	fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
 	if (fe0 && fe0->dvb.frontend)
 		videobuf_dvb_unregister_bus(&port->frontends);
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index 0e086c0..1040b3e 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -326,6 +326,9 @@ struct cx23885_tsport {
 	/* Workaround for a temp dvb_frontend that the tuner can attached to */
 	struct dvb_frontend analog_fe;
 
+	struct i2c_client *i2c_client_demod;
+	struct i2c_client *i2c_client_tuner;
+
 	int (*set_frontend)(struct dvb_frontend *fe);
 };
 
-- 
1.9.1


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

* [PATCH 5/6] cx23855: add frontend set voltage function into state
  2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
                   ` (2 preceding siblings ...)
  2014-08-11 19:58 ` [PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state Olli Salonen
@ 2014-08-11 19:58 ` Olli Salonen
  2014-08-12 23:28   ` Antti Palosaari
  2014-08-11 19:58 ` [PATCH 6/6] cx23855: add support for DVBSky T9580 DVB-C/T2/S2 tuner Olli Salonen
  2014-08-12 23:21 ` [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Antti Palosaari
  5 siblings, 1 reply; 11+ messages in thread
From: Olli Salonen @ 2014-08-11 19:58 UTC (permalink / raw)
  To: olli; +Cc: Olli Salonen, Linux Media Mailing List

Setting the LNB voltage requires setting some GPIOs on the cx23885 with some boards before calling the actual set_voltage function in the demod driver. Add a function pointer into state for that case.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/pci/cx23885/cx23885.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index 1040b3e..e60ff7f 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -330,6 +330,8 @@ struct cx23885_tsport {
 	struct i2c_client *i2c_client_tuner;
 
 	int (*set_frontend)(struct dvb_frontend *fe);
+	int (*fe_set_voltage)(struct dvb_frontend *fe,
+				fe_sec_voltage_t voltage);
 };
 
 struct cx23885_kernel_ir {
-- 
1.9.1


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

* [PATCH 6/6] cx23855: add support for DVBSky T9580 DVB-C/T2/S2 tuner
  2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
                   ` (3 preceding siblings ...)
  2014-08-11 19:58 ` [PATCH 5/6] cx23855: add frontend set voltage function into state Olli Salonen
@ 2014-08-11 19:58 ` Olli Salonen
  2014-08-12 23:21 ` [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Antti Palosaari
  5 siblings, 0 replies; 11+ messages in thread
From: Olli Salonen @ 2014-08-11 19:58 UTC (permalink / raw)
  To: olli; +Cc: Olli Salonen, Linux Media Mailing List

DVBSky T9580 is a dual tuner card with one DVB-T2/C tuner and one DVB-S2 tuner. It contains the following components:

- PCIe bridge: Conexant CX23885
- Demod for terrestrial/cable: Silicon Labs Si2168-A30
- Tuner for terrestrial/cable: Silicon Labs Si2158-A20
- Demod for sat: Montage DS3103
- Tuner for sat: Montage TS2022

This patch depends on Max Nibble's patch for m88ds3103 (see patchwork 25312: https://patchwork.linuxtv.org/patch/25312/ ).

3 firmwares are needed:
- Si2168-A30 demod and Si2158-A20 tuner: same as TechnoTrend CT2-4400, https://www.mail-archive.com/linux-media@vger.kernel.org/msg76944.html
- Montage DS3103 demod: same as PCTV 461e, Antti has it on his LinuxTV project page: http://palosaari.fi/linux/v4l-dvb/firmware/M88DS3103/

IR receiver is not supported.

Values in cx23885_gpio_setup, cx23885_card_setup and dvbsky_t9580_set_voltage as well as the EEPROM read function are taken from the manufacturer provided semi-open source driver. The drivers in question are Linux GPL'd media tree drivers for cx23885 modified by Max Nibble (nibble.max@gmail.com) with proprietary tuner/demod drivers. Max is aware of this patch and has approved my use of the values in this patch.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/pci/cx23885/Kconfig         |   4 +
 drivers/media/pci/cx23885/cx23885-cards.c |  26 +++++
 drivers/media/pci/cx23885/cx23885-dvb.c   | 160 ++++++++++++++++++++++++++++++
 drivers/media/pci/cx23885/cx23885.h       |   1 +
 4 files changed, 191 insertions(+)

diff --git a/drivers/media/pci/cx23885/Kconfig b/drivers/media/pci/cx23885/Kconfig
index e12c006..413587e 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -32,12 +32,16 @@ config VIDEO_CX23885
 	select DVB_A8293 if MEDIA_SUBDRV_AUTOSELECT
 	select DVB_MB86A20S if MEDIA_SUBDRV_AUTOSELECT
 	select DVB_SI2165 if MEDIA_SUBDRV_AUTOSELECT
+	select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
+	select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_MT2063 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_MT2131 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_XC2028 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_TDA8290 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT
+	select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
+	select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT
 	select DVB_TUNER_DIB0070 if MEDIA_SUBDRV_AUTOSELECT
 	---help---
 	  This is a video4linux driver for Conexant 23885 based
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index c2b6080..c1b02bb 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -679,6 +679,11 @@ struct cx23885_board cx23885_boards[] = {
 			.amux   = CX25840_AUDIO7,
 		} },
 	},
+	[CX23885_BOARD_DVBSKY_T9580] = {
+		.name		= "DVBSky T9580",
+		.portb		= CX23885_MPEG_DVB,
+		.portc		= CX23885_MPEG_DVB,
+	},
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -934,6 +939,10 @@ struct cx23885_subid cx23885_subids[] = {
 		.subvendor = 0x18ac,
 		.subdevice = 0xdb98,
 		.card      = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2,
+	}, {
+		.subvendor = 0x4254,
+		.subdevice = 0x9580,
+		.card      = CX23885_BOARD_DVBSKY_T9580,
 	},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1528,6 +1537,14 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
 		cx_set(GP0_IO, 0x00040004);
 		mdelay(60);
 		break;
+	case CX23885_BOARD_DVBSKY_T9580:
+		/* enable GPIO3-18 pins */
+		cx_write(MC417_CTL, 0x00000037);
+		cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
+		cx23885_gpio_clear(dev, GPIO_2 | GPIO_11);
+		mdelay(100);
+		cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
+		break;
 	}
 }
 
@@ -1851,6 +1868,14 @@ void cx23885_card_setup(struct cx23885_dev *dev)
 		ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
 		ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
 		break;
+	case CX23885_BOARD_DVBSKY_T9580:
+		ts1->gen_ctrl_val  = 0x5; /* Parallel */
+		ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
+		ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+		ts2->gen_ctrl_val  = 0x8; /* Serial bus */
+		ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
+		ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+		break;
 	case CX23885_BOARD_HAUPPAUGE_HVR1250:
 	case CX23885_BOARD_HAUPPAUGE_HVR1500:
 	case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
@@ -1913,6 +1938,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
 	case CX23885_BOARD_AVERMEDIA_HC81R:
 	case CX23885_BOARD_TBS_6980:
 	case CX23885_BOARD_TBS_6981:
+	case CX23885_BOARD_DVBSKY_T9580:
 		dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
 				&dev->i2c_bus[2].i2c_adap,
 				"cx25840", 0x88 >> 1, NULL);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 2608155..1e9e041 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -73,6 +73,10 @@
 #include "a8293.h"
 #include "mb86a20s.h"
 #include "si2165.h"
+#include "si2168.h"
+#include "si2157.h"
+#include "m88ds3103.h"
+#include "m88ts2022.h"
 
 static unsigned int debug;
 
@@ -551,6 +555,35 @@ static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
 	return 0;
 }
 
+static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
+					fe_sec_voltage_t voltage)
+{
+	struct cx23885_tsport *port = fe->dvb->priv;
+	struct cx23885_dev *dev = port->dev;
+
+	cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
+
+	switch (voltage) {
+	case SEC_VOLTAGE_13:
+		cx23885_gpio_set(dev, GPIO_1);
+		cx23885_gpio_clear(dev, GPIO_0);
+		break;
+	case SEC_VOLTAGE_18:
+		cx23885_gpio_set(dev, GPIO_1);
+		cx23885_gpio_set(dev, GPIO_0);
+		break;
+	case SEC_VOLTAGE_OFF:
+		cx23885_gpio_clear(dev, GPIO_1);
+		cx23885_gpio_clear(dev, GPIO_0);
+		break;
+	}
+
+	/* call the frontend set_voltage function */
+	port->fe_set_voltage(fe, voltage);
+
+	return 0;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
 	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
@@ -715,6 +748,19 @@ static const struct si2165_config hauppauge_hvr4400_si2165_config = {
 	.ref_freq_Hz	= 16000000,
 };
 
+static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
+	.i2c_addr = 0x68,
+	.clock = 27000000,
+	.i2c_wr_max = 33,
+	.clock_out = 0,
+	.ts_mode = M88DS3103_TS_PARALLEL,
+	.ts_clk = 16000,
+	.ts_clk_pol = 1,
+	.lnb_en_pol = 1,
+	.lnb_hv_pol = 0,
+	.agc = 0x99,
+};
+
 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
 {
 	struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -864,6 +910,13 @@ static int dvb_register(struct cx23885_tsport *port)
 	struct cx23885_dev *dev = port->dev;
 	struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
 	struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
+	struct si2168_config si2168_config;
+	struct si2157_config si2157_config;
+	struct m88ts2022_config m88ts2022_config;
+	struct i2c_board_info info;
+	struct i2c_adapter *adapter;
+	struct i2c_client *client_demod;
+	struct i2c_client *client_tuner;
 	int mfe_shared = 0; /* bus not shared by default */
 	int ret;
 
@@ -1501,6 +1554,97 @@ static int dvb_register(struct cx23885_tsport *port)
 			break;
 		}
 		break;
+	case CX23885_BOARD_DVBSKY_T9580:
+		i2c_bus = &dev->i2c_bus[0];
+		i2c_bus2 = &dev->i2c_bus[1];
+		switch (port->nr) {
+		/* port b - satellite */
+		case 1:
+			/* attach frontend */
+			fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
+					&dvbsky_t9580_m88ds3103_config,
+					&i2c_bus2->i2c_adap, &adapter);
+			if (fe0->dvb.frontend == NULL)
+				break;
+
+			/* attach tuner */
+			m88ts2022_config.fe = fe0->dvb.frontend;
+			m88ts2022_config.clock = 27000000;
+			memset(&info, 0, sizeof(struct i2c_board_info));
+			strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE);
+			info.addr = 0x60;
+			info.platform_data = &m88ts2022_config;
+			request_module(info.type);
+			client_tuner = i2c_new_device(adapter, &info);
+			if (client_tuner == NULL ||
+					client_tuner->dev.driver == NULL)
+				goto frontend_detach;
+			if (!try_module_get(client_tuner->dev.driver->owner)) {
+				i2c_unregister_device(client_tuner);
+				goto frontend_detach;
+			}
+
+			/* delegate signal strength measurement to tuner */
+			fe0->dvb.frontend->ops.read_signal_strength =
+				fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
+
+			/*
+			 * for setting the voltage we need to set GPIOs on
+			 * the card.
+			 */
+			port->fe_set_voltage =
+				fe0->dvb.frontend->ops.set_voltage;
+			fe0->dvb.frontend->ops.set_voltage =
+				dvbsky_t9580_set_voltage;
+
+			port->i2c_client_tuner = client_tuner;
+
+			break;
+		/* port c - terrestrial/cable */
+		case 2:
+			/* attach frontend */
+			si2168_config.i2c_adapter = &adapter;
+			si2168_config.fe = &fe0->dvb.frontend;
+			si2168_config.ts_mode = SI2168_TS_SERIAL;
+			memset(&info, 0, sizeof(struct i2c_board_info));
+			strlcpy(info.type, "si2168", I2C_NAME_SIZE);
+			info.addr = 0x64;
+			info.platform_data = &si2168_config;
+			request_module(info.type);
+			client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
+			if (client_demod == NULL ||
+					client_demod->dev.driver == NULL)
+				goto frontend_detach;
+			if (!try_module_get(client_demod->dev.driver->owner)) {
+				i2c_unregister_device(client_demod);
+				goto frontend_detach;
+			}
+			port->i2c_client_demod = client_demod;
+
+			/* attach tuner */
+			si2157_config.fe = fe0->dvb.frontend;
+			memset(&info, 0, sizeof(struct i2c_board_info));
+			strlcpy(info.type, "si2157", I2C_NAME_SIZE);
+			info.addr = 0x60;
+			info.platform_data = &si2157_config;
+			request_module(info.type);
+			client_tuner = i2c_new_device(adapter, &info);
+			if (client_tuner == NULL ||
+					client_tuner->dev.driver == NULL) {
+				module_put(client_demod->dev.driver->owner);
+				i2c_unregister_device(client_demod);
+				goto frontend_detach;
+			}
+			if (!try_module_get(client_tuner->dev.driver->owner)) {
+				i2c_unregister_device(client_tuner);
+				module_put(client_demod->dev.driver->owner);
+				i2c_unregister_device(client_demod);
+				goto frontend_detach;
+			}
+			port->i2c_client_tuner = client_tuner;
+			break;
+		}
+		break;
 	default:
 		printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
 			" isn't supported yet\n",
@@ -1575,6 +1719,22 @@ static int dvb_register(struct cx23885_tsport *port)
 		memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
 		break;
 		}
+	case CX23885_BOARD_DVBSKY_T9580: {
+		u8 eeprom[256]; /* 24C02 i2c eeprom */
+
+		if (port->nr > 2)
+			break;
+
+		/* Read entire EEPROM */
+		dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
+		tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
+				sizeof(eeprom));
+		printk(KERN_INFO "DVBSky T9580 port %d MAC address: %pM\n",
+			port->nr, eeprom + 0xc0 + (port->nr-1) * 8);
+		memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
+			(port->nr-1) * 8, 6);
+		break;
+		}
 	}
 
 	return ret;
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index e60ff7f..f9a23b6 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -98,6 +98,7 @@
 #define CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200 42
 #define CX23885_BOARD_HAUPPAUGE_IMPACTVCBE     43
 #define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2 44
+#define CX23885_BOARD_DVBSKY_T9580             45
 
 #define GPIO_0 0x00000001
 #define GPIO_1 0x00000002
-- 
1.9.1


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

* Re: [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init
  2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
                   ` (4 preceding siblings ...)
  2014-08-11 19:58 ` [PATCH 6/6] cx23855: add support for DVBSky T9580 DVB-C/T2/S2 tuner Olli Salonen
@ 2014-08-12 23:21 ` Antti Palosaari
  5 siblings, 0 replies; 11+ messages in thread
From: Antti Palosaari @ 2014-08-12 23:21 UTC (permalink / raw)
  To: Olli Salonen, olli; +Cc: Linux Media Mailing List

Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>

Antti


On 08/11/2014 10:58 PM, Olli Salonen wrote:
> Luis Alves submitted a TS mode patch to si2168 earlier, but the patch was rejected due to a small issue. Here is a working version. Also, setting of TS mode is moved from si2168_set_frontend to si2168_init.
>
> This patch adds the TS mode as a config option for the si2168 demod:
> - ts_mode added to config struct.
> - Possible (interesting) values are
>     * Parallel mode = 0x06
>     * Serial mode = 0x03
>
> Currently the modules using this demod only use parallel mode. Patches for these modules later in this patch series.
>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
> ---
>   drivers/media/dvb-frontends/si2168.c      | 17 ++++++++++-------
>   drivers/media/dvb-frontends/si2168.h      |  6 ++++++
>   drivers/media/dvb-frontends/si2168_priv.h |  1 +
>   3 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
> index 8f81d97..0eb0e4e 100644
> --- a/drivers/media/dvb-frontends/si2168.c
> +++ b/drivers/media/dvb-frontends/si2168.c
> @@ -297,13 +297,6 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
>   	if (ret)
>   		goto err;
>
> -	memcpy(cmd.args, "\x14\x00\x01\x10\x16\x00", 6);
> -	cmd.wlen = 6;
> -	cmd.rlen = 4;
> -	ret = si2168_cmd_execute(s, &cmd);
> -	if (ret)
> -		goto err;
> -
>   	memcpy(cmd.args, "\x14\x00\x09\x10\xe3\x18", 6);
>   	cmd.wlen = 6;
>   	cmd.rlen = 4;
> @@ -465,6 +458,15 @@ static int si2168_init(struct dvb_frontend *fe)
>   	dev_info(&s->client->dev, "%s: found a '%s' in warm state\n",
>   			KBUILD_MODNAME, si2168_ops.info.name);
>
> +	/* set ts mode */
> +	memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
> +	cmd.args[4] |= s->ts_mode;
> +	cmd.wlen = 6;
> +	cmd.rlen = 4;
> +	ret = si2168_cmd_execute(s, &cmd);
> +	if (ret)
> +		goto err;
> +
>   	s->active = true;
>
>   	return 0;
> @@ -633,6 +635,7 @@ static int si2168_probe(struct i2c_client *client,
>
>   	*config->i2c_adapter = s->adapter;
>   	*config->fe = &s->fe;
> +	s->ts_mode = config->ts_mode;
>
>   	i2c_set_clientdata(client, s);
>
> diff --git a/drivers/media/dvb-frontends/si2168.h b/drivers/media/dvb-frontends/si2168.h
> index 3c5b5ab..e086d67 100644
> --- a/drivers/media/dvb-frontends/si2168.h
> +++ b/drivers/media/dvb-frontends/si2168.h
> @@ -34,6 +34,12 @@ struct si2168_config {
>   	 * returned by driver
>   	 */
>   	struct i2c_adapter **i2c_adapter;
> +
> +	/* TS mode */
> +	u8 ts_mode;
>   };
>
> +#define SI2168_TS_PARALLEL	0x06
> +#define SI2168_TS_SERIAL	0x03
> +
>   #endif
> diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h
> index ebbf502..0f83284 100644
> --- a/drivers/media/dvb-frontends/si2168_priv.h
> +++ b/drivers/media/dvb-frontends/si2168_priv.h
> @@ -36,6 +36,7 @@ struct si2168 {
>   	fe_delivery_system_t delivery_system;
>   	fe_status_t fe_status;
>   	bool active;
> +	u8 ts_mode;
>   };
>
>   /* firmare command struct */
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e
  2014-08-11 19:58 ` [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e Olli Salonen
@ 2014-08-12 23:23   ` Antti Palosaari
  0 siblings, 0 replies; 11+ messages in thread
From: Antti Palosaari @ 2014-08-12 23:23 UTC (permalink / raw)
  To: Olli Salonen, olli; +Cc: Linux Media Mailing List

Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>

PCTV 461e is satellite receiver whilst that one should be PCTV 292e. I 
will fix the type, no new patch needed.

Antti


On 08/11/2014 10:58 PM, Olli Salonen wrote:
> TS mode must be set in the existing PCTV 461e driver.
>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
> ---
>   drivers/media/usb/em28xx/em28xx-dvb.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
> index d8e9760..0645793 100644
> --- a/drivers/media/usb/em28xx/em28xx-dvb.c
> +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
> @@ -1535,6 +1535,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
>   			/* attach demod */
>   			si2168_config.i2c_adapter = &adapter;
>   			si2168_config.fe = &dvb->fe[0];
> +			si2168_config.ts_mode = SI2168_TS_PARALLEL;
>   			memset(&info, 0, sizeof(struct i2c_board_info));
>   			strlcpy(info.type, "si2168", I2C_NAME_SIZE);
>   			info.addr = 0x64;
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400
  2014-08-11 19:58 ` [PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400 Olli Salonen
@ 2014-08-12 23:25   ` Antti Palosaari
  0 siblings, 0 replies; 11+ messages in thread
From: Antti Palosaari @ 2014-08-12 23:25 UTC (permalink / raw)
  To: Olli Salonen, olli; +Cc: Linux Media Mailing List

Reviewed-by: Antti Palosaari <crope@iki.fi>

Antti

On 08/11/2014 10:58 PM, Olli Salonen wrote:
> TS mode must be set in the existing TechnoTrend CT2-4400 driver.
>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
> ---
>   drivers/media/usb/dvb-usb/cxusb.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
> index 16bc579..87842e9 100644
> --- a/drivers/media/usb/dvb-usb/cxusb.c
> +++ b/drivers/media/usb/dvb-usb/cxusb.c
> @@ -1369,6 +1369,7 @@ static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
>   	/* attach frontend */
>   	si2168_config.i2c_adapter = &adapter;
>   	si2168_config.fe = &adap->fe_adap[0].fe;
> +	si2168_config.ts_mode = SI2168_TS_PARALLEL;
>   	memset(&info, 0, sizeof(struct i2c_board_info));
>   	strlcpy(info.type, "si2168", I2C_NAME_SIZE);
>   	info.addr = 0x64;
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state
  2014-08-11 19:58 ` [PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state Olli Salonen
@ 2014-08-12 23:27   ` Antti Palosaari
  0 siblings, 0 replies; 11+ messages in thread
From: Antti Palosaari @ 2014-08-12 23:27 UTC (permalink / raw)
  To: Olli Salonen, olli; +Cc: Linux Media Mailing List

Reviewed-by: Antti Palosaari <crope@iki.fi>

Antti

On 08/11/2014 10:58 PM, Olli Salonen wrote:
> Prepare cx23885 driver for handling I2C client that is needed for certain demodulators and tuners (for example Si2168 and Si2157). I2C client for tuner and demod stored in state and unregistering of the I2C devices added into dvb_unregister.
>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
> ---
>   drivers/media/pci/cx23885/cx23885-dvb.c | 16 ++++++++++++++++
>   drivers/media/pci/cx23885/cx23885.h     |  3 +++
>   2 files changed, 19 insertions(+)
>
> diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
> index 968fecc..2608155 100644
> --- a/drivers/media/pci/cx23885/cx23885-dvb.c
> +++ b/drivers/media/pci/cx23885/cx23885-dvb.c
> @@ -1643,6 +1643,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
>   int cx23885_dvb_unregister(struct cx23885_tsport *port)
>   {
>   	struct videobuf_dvb_frontend *fe0;
> +	struct i2c_client *client;
>
>   	/* FIXME: in an error condition where the we have
>   	 * an expected number of frontends (attach problem)
> @@ -1651,6 +1652,21 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
>   	 * This comment only applies to future boards IF they
>   	 * implement MFE support.
>   	 */
> +
> +	/* remove I2C client for tuner */
> +	client = port->i2c_client_tuner;
> +	if (client) {
> +		module_put(client->dev.driver->owner);
> +		i2c_unregister_device(client);
> +	}
> +
> +	/* remove I2C client for demodulator */
> +	client = port->i2c_client_demod;
> +	if (client) {
> +		module_put(client->dev.driver->owner);
> +		i2c_unregister_device(client);
> +	}
> +
>   	fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
>   	if (fe0 && fe0->dvb.frontend)
>   		videobuf_dvb_unregister_bus(&port->frontends);
> diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
> index 0e086c0..1040b3e 100644
> --- a/drivers/media/pci/cx23885/cx23885.h
> +++ b/drivers/media/pci/cx23885/cx23885.h
> @@ -326,6 +326,9 @@ struct cx23885_tsport {
>   	/* Workaround for a temp dvb_frontend that the tuner can attached to */
>   	struct dvb_frontend analog_fe;
>
> +	struct i2c_client *i2c_client_demod;
> +	struct i2c_client *i2c_client_tuner;
> +
>   	int (*set_frontend)(struct dvb_frontend *fe);
>   };
>
>

-- 
http://palosaari.fi/

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

* Re: [PATCH 5/6] cx23855: add frontend set voltage function into state
  2014-08-11 19:58 ` [PATCH 5/6] cx23855: add frontend set voltage function into state Olli Salonen
@ 2014-08-12 23:28   ` Antti Palosaari
  0 siblings, 0 replies; 11+ messages in thread
From: Antti Palosaari @ 2014-08-12 23:28 UTC (permalink / raw)
  To: Olli Salonen, olli; +Cc: Linux Media Mailing List

Acked-by: Antti Palosaari <crope@iki.fi>
Reviewed-by: Antti Palosaari <crope@iki.fi>

Antti

On 08/11/2014 10:58 PM, Olli Salonen wrote:
> Setting the LNB voltage requires setting some GPIOs on the cx23885 with some boards before calling the actual set_voltage function in the demod driver. Add a function pointer into state for that case.
>
> Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
> ---
>   drivers/media/pci/cx23885/cx23885.h | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
> index 1040b3e..e60ff7f 100644
> --- a/drivers/media/pci/cx23885/cx23885.h
> +++ b/drivers/media/pci/cx23885/cx23885.h
> @@ -330,6 +330,8 @@ struct cx23885_tsport {
>   	struct i2c_client *i2c_client_tuner;
>
>   	int (*set_frontend)(struct dvb_frontend *fe);
> +	int (*fe_set_voltage)(struct dvb_frontend *fe,
> +				fe_sec_voltage_t voltage);
>   };
>
>   struct cx23885_kernel_ir {
>

-- 
http://palosaari.fi/

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

end of thread, other threads:[~2014-08-12 23:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-11 19:58 [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Olli Salonen
2014-08-11 19:58 ` [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e Olli Salonen
2014-08-12 23:23   ` Antti Palosaari
2014-08-11 19:58 ` [PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400 Olli Salonen
2014-08-12 23:25   ` Antti Palosaari
2014-08-11 19:58 ` [PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state Olli Salonen
2014-08-12 23:27   ` Antti Palosaari
2014-08-11 19:58 ` [PATCH 5/6] cx23855: add frontend set voltage function into state Olli Salonen
2014-08-12 23:28   ` Antti Palosaari
2014-08-11 19:58 ` [PATCH 6/6] cx23855: add support for DVBSky T9580 DVB-C/T2/S2 tuner Olli Salonen
2014-08-12 23:21 ` [PATCH 1/6] si2168: add ts_mode setting and move to si2168_init Antti Palosaari

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.