[PATCH 0/6] [0b48:3014] TechnoTrend TVStick CT2-4400

2014-07-13 Thread Olli Salonen
TechnoTrend TVStick CT2-4400 is a USB 2.0 DVB C/T/T2 tuner with the
following components.

USB bridge: Cypress FX2
Demodulator: Silicon Labs Si2168-A30
Tuner: Silicon Labs Si2158-A20

Both the demodulator and the tuner need a firmware. These can be
extracted from TT drivers.

Download: http://www.tt-downloads.de/bda-treiber_4.2.0.0.zip

Extract firmware from file ttTVStick4400_64.sys in the zip (MD5 sum below):
0276023ce027bab05c2e7053033e2182  ttTVStick4400_64.sys

dd if=ttTVStick4400_64.sys ibs=1 skip=211216 count=17576 
of=dvb-demod-si2168-30-01.fw
dd if=ttTVStick4400_64.sys ibs=1 skip=200816 count=3944 
of=dvb-tuner-si2158-20-01.fw

Olli Salonen (6):
  si2168: Small typo fix (SI2157 - SI2168)
  si2168: Add handling for different chip revisions and firmwares
  si2157: Move chip initialization to si2157_init
  si2157: Add support for Si2158 chip
  si2157: Set delivery system and bandwidth before tuning
  cxusb: TechnoTrend CT2-4400 USB DVB-T2/C tuner support

 drivers/media/dvb-core/dvb-usb-ids.h  |   1 +
 drivers/media/dvb-frontends/si2168.c  |  34 +-
 drivers/media/dvb-frontends/si2168_priv.h |   8 +-
 drivers/media/tuners/si2157.c | 161 +++--
 drivers/media/tuners/si2157.h |   2 +-
 drivers/media/tuners/si2157_priv.h|   5 +-
 drivers/media/usb/dvb-usb/Kconfig |   3 +
 drivers/media/usb/dvb-usb/cxusb.c | 191 +-
 drivers/media/usb/dvb-usb/cxusb.h |   2 +
 9 files changed, 357 insertions(+), 50 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] si2168: Add handling for different chip revisions and firmwares

2014-07-13 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c  | 34 ++-
 drivers/media/dvb-frontends/si2168_priv.h |  4 +++-
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index bae7771..268fce3 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -333,7 +333,7 @@ static int si2168_init(struct dvb_frontend *fe)
struct si2168 *s = fe-demodulator_priv;
int ret, len, remaining;
const struct firmware *fw = NULL;
-   u8 *fw_file = SI2168_FIRMWARE;
+   u8 *fw_file;
const unsigned int i2c_wr_max = 8;
struct si2168_cmd cmd;
 
@@ -353,6 +353,7 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   /* query chip revision */
memcpy(cmd.args, \x02, 1);
cmd.wlen = 1;
cmd.rlen = 13;
@@ -360,6 +361,20 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   if (((cmd.args[1]  0x0f) == 2)  (cmd.args[3] == '4') 
+   (cmd.args[4] == '0'))
+   fw_file = SI2168_B40_FIRMWARE;
+   else if (((cmd.args[1]  0x0f) == 1)  (cmd.args[3] == '3') 
+   (cmd.args[4] == '0'))
+   fw_file = SI2168_A30_FIRMWARE;
+   else {
+   dev_err(s-client-dev,
+   %s: no firmware file for Si2168-%c%c 
defined\n,
+   KBUILD_MODNAME, cmd.args[3], cmd.args[4]);
+   ret = -EINVAL;
+   goto err;
+   }
+
/* cold state - try to download firmware */
dev_info(s-client-dev, %s: found a '%s' in cold state\n,
KBUILD_MODNAME, si2168_ops.info.name);
@@ -367,9 +382,18 @@ static int si2168_init(struct dvb_frontend *fe)
/* request the firmware, this will block and timeout */
ret = request_firmware(fw, fw_file, s-client-dev);
if (ret) {
-   dev_err(s-client-dev, %s: firmare file '%s' not found\n,
-   KBUILD_MODNAME, fw_file);
-   goto err;
+   /* fallback mechanism to handle old name for
+  SI2168_B40_FIRMWARE */
+   if (((cmd.args[1]  0x0f) == 2)  (cmd.args[3] == '4') 
+   (cmd.args[4] == '0')) {
+   fw_file = SI2168_B40_FIRMWARE_FALLBACK;
+   ret = request_firmware(fw, fw_file, s-client-dev);
+   }
+   if (ret) {
+   dev_err(s-client-dev, %s: firmware file '%s' not 
found\n,
+   KBUILD_MODNAME, fw_file);
+   goto err;
+   }
}
 
dev_info(s-client-dev, %s: downloading firmware from file '%s'\n,
@@ -629,4 +653,4 @@ module_i2c_driver(si2168_driver);
 MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
 MODULE_DESCRIPTION(Silicon Labs Si2168 DVB-T/T2/C demodulator driver);
 MODULE_LICENSE(GPL);
-MODULE_FIRMWARE(SI2168_FIRMWARE);
+MODULE_FIRMWARE(SI2168_B40_FIRMWARE);
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 97f9d87..bebb68a 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -22,7 +22,9 @@
 #include linux/firmware.h
 #include linux/i2c-mux.h
 
-#define SI2168_FIRMWARE dvb-demod-si2168-02.fw
+#define SI2168_A30_FIRMWARE dvb-demod-si2168-a30-01.fw
+#define SI2168_B40_FIRMWARE dvb-demod-si2168-b40-01.fw
+#define SI2168_B40_FIRMWARE_FALLBACK dvb-demod-si2168-02.fw
 
 /* state struct */
 struct si2168 {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] si2168: Small typo fix (SI2157 - SI2168)

2014-07-13 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168_priv.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 53f7f06..97f9d87 100644
--- a/drivers/media/dvb-frontends/si2168_priv.h
+++ b/drivers/media/dvb-frontends/si2168_priv.h
@@ -36,9 +36,9 @@ struct si2168 {
 };
 
 /* firmare command struct */
-#define SI2157_ARGLEN  30
+#define SI2168_ARGLEN  30
 struct si2168_cmd {
-   u8 args[SI2157_ARGLEN];
+   u8 args[SI2168_ARGLEN];
unsigned wlen;
unsigned rlen;
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] si2157: Add support for Si2158 chip

2014-07-13 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 73 +++---
 drivers/media/tuners/si2157.h  |  2 +-
 drivers/media/tuners/si2157_priv.h |  5 ++-
 3 files changed, 73 insertions(+), 7 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index a92570f9..58c5ef5 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157 silicon tuner driver
+ * Silicon Labs Si2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
@@ -16,6 +16,8 @@
 
 #include si2157_priv.h
 
+static const struct dvb_tuner_ops si2157_ops;
+
 /* execute firmware command */
 static int si2157_cmd_execute(struct si2157 *s, struct si2157_cmd *cmd)
 {
@@ -80,8 +82,11 @@ err:
 static int si2157_init(struct dvb_frontend *fe)
 {
struct si2157 *s = fe-tuner_priv;
-   int ret;
+   int ret, remaining;
struct si2157_cmd cmd;
+   u8 chip, len = 0;
+   const struct firmware *fw = NULL;
+   u8 *fw_file;
 
dev_dbg(s-client-dev, %s:\n, __func__);
 
@@ -101,6 +106,64 @@ static int si2157_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   chip = cmd.args[2]; /* 57 for Si2157, 58 for Si2158 */
+
+   /* Si2158 requires firmware download */
+   if (chip == 58) {
+   if (((cmd.args[1]  0x0f) == 1)  (cmd.args[3] == '2') 
+   (cmd.args[4] == '0'))
+   fw_file = SI2158_A20_FIRMWARE;
+   else {
+   dev_err(s-client-dev,
+   %s: no firmware file for Si%d-%c%c 
defined\n,
+   KBUILD_MODNAME, chip, cmd.args[3], 
cmd.args[4]);
+   ret = -EINVAL;
+   goto err;
+   }
+
+   /* cold state - try to download firmware */
+   dev_info(s-client-dev, %s: found a '%s' in cold state\n,
+   KBUILD_MODNAME, si2157_ops.info.name);
+
+   /* request the firmware, this will block and timeout */
+   ret = request_firmware(fw, fw_file, s-client-dev);
+   if (ret) {
+   dev_err(s-client-dev, %s: firmware file '%s' not 
found\n,
+   KBUILD_MODNAME, fw_file);
+   goto err;
+   }
+
+   dev_info(s-client-dev, %s: downloading firmware from file 
'%s'\n,
+   KBUILD_MODNAME, fw_file);
+
+   /* firmware should be n chunks of 17 bytes */
+   if (fw-size % 17 != 0) {
+   dev_err(s-client-dev, %s: firmware file '%s' is 
invalid\n,
+   KBUILD_MODNAME, fw_file);
+   ret = -EINVAL;
+   goto err;
+   }
+
+   for (remaining = fw-size; remaining  0; remaining -= 17) {
+   memcpy(len, fw-data[fw-size - remaining], 1);
+   memcpy(cmd.args, fw-data[(fw-size - remaining) + 1],
+   len);
+   cmd.wlen = len;
+   cmd.rlen = 1;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret) {
+   dev_err(s-client-dev,
+   %s: firmware download 
failed=%d\n,
+   KBUILD_MODNAME, ret);
+   goto err;
+   }
+   }
+
+   release_firmware(fw);
+   fw = NULL;
+
+   }
+
/* reboot the tuner with new firmware? */
memcpy(cmd.args, \x01\x01, 2);
cmd.wlen = 2;
@@ -177,7 +240,7 @@ err:
 
 static const struct dvb_tuner_ops si2157_tuner_ops = {
.info = {
-   .name   = Silicon Labs Si2157,
+   .name   = Silicon Labs Si2157/Si2158,
.frequency_min  = 11000,
.frequency_max  = 86200,
},
@@ -221,7 +284,7 @@ static int si2157_probe(struct i2c_client *client,
i2c_set_clientdata(client, s);
 
dev_info(s-client-dev,
-   %s: Silicon Labs Si2157 successfully attached\n,
+   %s: Silicon Labs Si2157/Si2158 successfully 
attached\n,
KBUILD_MODNAME);
return 0;
 err:
@@ -263,6 +326,6 @@ static struct i2c_driver si2157_driver = {
 
 module_i2c_driver(si2157_driver);
 
-MODULE_DESCRIPTION(Silicon Labs Si2157 silicon tuner driver);
+MODULE_DESCRIPTION(Silicon Labs Si2157/Si2158 silicon tuner driver);
 MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
 MODULE_LICENSE(GPL);
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index f469a09

[PATCH 3/6] si2157: Move chip initialization to si2157_init

2014-07-13 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 71 ++-
 1 file changed, 30 insertions(+), 41 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index a4908ee..a92570f9 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -80,12 +80,41 @@ err:
 static int si2157_init(struct dvb_frontend *fe)
 {
struct si2157 *s = fe-tuner_priv;
+   int ret;
+   struct si2157_cmd cmd;
 
dev_dbg(s-client-dev, %s:\n, __func__);
 
+   /* configure? */
+   memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
+   cmd.wlen = 15;
+   cmd.rlen = 1;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   /* query chip revision */
+   memcpy(cmd.args, \x02, 1);
+   cmd.wlen = 1;
+   cmd.rlen = 13;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   /* reboot the tuner with new firmware? */
+   memcpy(cmd.args, \x01\x01, 2);
+   cmd.wlen = 2;
+   cmd.rlen = 1;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
s-active = true;
 
return 0;
+err:
+   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   return ret;
 }
 
 static int si2157_sleep(struct dvb_frontend *fe)
@@ -128,48 +157,8 @@ static int si2157_set_params(struct dvb_frontend *fe)
goto err;
}
 
-   /* configure? */
-   cmd.args[0] = 0xc0;
-   cmd.args[1] = 0x00;
-   cmd.args[2] = 0x0c;
-   cmd.args[3] = 0x00;
-   cmd.args[4] = 0x00;
-   cmd.args[5] = 0x01;
-   cmd.args[6] = 0x01;
-   cmd.args[7] = 0x01;
-   cmd.args[8] = 0x01;
-   cmd.args[9] = 0x01;
-   cmd.args[10] = 0x01;
-   cmd.args[11] = 0x02;
-   cmd.args[12] = 0x00;
-   cmd.args[13] = 0x00;
-   cmd.args[14] = 0x01;
-   cmd.wlen = 15;
-   cmd.rlen = 1;
-   ret = si2157_cmd_execute(s, cmd);
-   if (ret)
-   goto err;
-
-   cmd.args[0] = 0x02;
-   cmd.wlen = 1;
-   cmd.rlen = 13;
-   ret = si2157_cmd_execute(s, cmd);
-   if (ret)
-   goto err;
-
-   cmd.args[0] = 0x01;
-   cmd.args[1] = 0x01;
-   cmd.wlen = 2;
-   cmd.rlen = 1;
-   ret = si2157_cmd_execute(s, cmd);
-   if (ret)
-   goto err;
-
/* set frequency */
-   cmd.args[0] = 0x41;
-   cmd.args[1] = 0x00;
-   cmd.args[2] = 0x00;
-   cmd.args[3] = 0x00;
+   memcpy(cmd.args, \x41\x00\x00\x00\x00\x00\x00\x00, 8);
cmd.args[4] = (c-frequency   0)  0xff;
cmd.args[5] = (c-frequency   8)  0xff;
cmd.args[6] = (c-frequency  16)  0xff;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] si2157: Set delivery system and bandwidth before tuning

2014-07-13 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 58c5ef5..b656f9b 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -209,6 +209,7 @@ static int si2157_set_params(struct dvb_frontend *fe)
struct dtv_frontend_properties *c = fe-dtv_property_cache;
int ret;
struct si2157_cmd cmd;
+   u8 bandwidth, delivery_system;
 
dev_dbg(s-client-dev,
%s: delivery_system=%d frequency=%u bandwidth_hz=%u\n,
@@ -220,6 +221,36 @@ static int si2157_set_params(struct dvb_frontend *fe)
goto err;
}
 
+   if (c-bandwidth_hz = 600)
+   bandwidth = 0x06;
+   else if (c-bandwidth_hz = 700)
+   bandwidth = 0x07;
+   else if (c-bandwidth_hz = 800)
+   bandwidth = 0x08;
+   else
+   bandwidth = 0x0f;
+
+   switch (c-delivery_system) {
+   case SYS_DVBT:
+   case SYS_DVBT2: /* it seems DVB-T and DVB-T2 both are 0x20 here */
+   delivery_system = 0x20;
+   break;
+   case SYS_DVBC_ANNEX_A:
+   delivery_system = 0x30;
+   break;
+   default:
+   ret = -EINVAL;
+   goto err;
+   }
+
+   memcpy(cmd.args, \x14\x00\x03\x07\x00\x00, 6);
+   cmd.args[4] = delivery_system | bandwidth;
+   cmd.wlen = 6;
+   cmd.rlen = 1;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
/* set frequency */
memcpy(cmd.args, \x41\x00\x00\x00\x00\x00\x00\x00, 8);
cmd.args[4] = (c-frequency   0)  0xff;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] cxusb: TechnoTrend CT2-4400 USB DVB-T2/C tuner support

2014-07-13 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-core/dvb-usb-ids.h |   1 +
 drivers/media/usb/dvb-usb/Kconfig|   3 +
 drivers/media/usb/dvb-usb/cxusb.c| 191 ++-
 drivers/media/usb/dvb-usb/cxusb.h|   2 +
 4 files changed, 196 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 11d2bea..f8e3150 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -244,6 +244,7 @@
 #define USB_PID_TECHNOTREND_CONNECT_S2400   0x3006
 #define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
 #define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
+#define USB_PID_TECHNOTREND_TVSTICK_CT2_4400   0x3014
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY   0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
 #define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058
diff --git a/drivers/media/usb/dvb-usb/Kconfig 
b/drivers/media/usb/dvb-usb/Kconfig
index c5d9566..10aef21 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -117,10 +117,12 @@ config DVB_USB_CXUSB
select DVB_TUNER_DIB0070 if MEDIA_SUBDRV_AUTOSELECT
select DVB_ATBM8830 if MEDIA_SUBDRV_AUTOSELECT
select DVB_LGS8GXX if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_SIMPLE if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_XC2028 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MXL5005S if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MAX2165 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
help
  Say Y here to support the Conexant USB2.0 hybrid reference design.
  Currently, only DVB and ATSC modes are supported, analog mode
@@ -128,6 +130,7 @@ config DVB_USB_CXUSB
 
  Medion MD95700 hybrid USB2.0 device.
  DViCO FusionHDTV (Bluebird) USB2.0 devices
+ TechnoTrend TVStick CT2-4400
 
 config DVB_USB_M920X
tristate Uli m920x DVB-T USB2.0 support
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index a1c641e..ad20c39 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -42,6 +42,8 @@
 #include dib0070.h
 #include lgs8gxx.h
 #include atbm8830.h
+#include si2168.h
+#include si2157.h
 
 /* Max transfer size done by I2C transfer functions */
 #define MAX_XFER_SIZE  64
@@ -144,6 +146,22 @@ static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device 
*d,
}
 }
 
+static int cxusb_tt_ct2_4400_gpio_tuner(struct dvb_usb_device *d, int onoff)
+{
+   u8 o[2], i;
+   int rc;
+
+   o[0] = 0x83;
+   o[1] = onoff;
+   rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, i, 1);
+
+   if (rc) {
+   deb_info(gpio_write failed.\n);
+   return -EIO;
+   }
+   return 0;
+}
+
 /* I2C */
 static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  int num)
@@ -505,6 +523,30 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device 
*d, u32 *event,
return 0;
 }
 
+static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d)
+{
+   u8 i[2];
+   int ret;
+   u32 cmd, keycode;
+   u8 rc5_cmd, rc5_addr, rc5_toggle;
+
+   ret = cxusb_ctrl_msg(d, 0x10, NULL, 0, i, 2);
+   if (ret)
+   return ret;
+
+   cmd = (i[0]  8) | i[1];
+
+   if (cmd != 0x) {
+   rc5_cmd = cmd  0x3F; /* bits 1-6 for command */
+   rc5_addr = (cmd  0x07C0)  6; /* bits 7-11 for address */
+   rc5_toggle = (cmd  0x0800)  11; /* bit 12 for toggle */
+   keycode = (rc5_addr  8) | rc5_cmd;
+   rc_keydown(d-rc_dev, keycode, rc5_toggle);
+   }
+
+   return 0;
+}
+
 static struct rc_map_table rc_map_dvico_mce_table[] = {
{ 0xfe02, KEY_TV },
{ 0xfe0e, KEY_MP3 },
@@ -1286,6 +1328,73 @@ static int cxusb_mygica_d689_frontend_attach(struct 
dvb_usb_adapter *adap)
return 0;
 }
 
+static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
+{
+   struct dvb_usb_device *d = adap-dev;
+   struct cxusb_state *st = d-priv;
+   struct i2c_adapter *adapter;
+   struct i2c_client *client_demod;
+   struct i2c_client *client_tuner;
+   struct i2c_board_info info;
+   struct si2168_config si2168_config;
+   struct si2157_config si2157_config;
+
+   /* reset the tuner */
+   if (cxusb_tt_ct2_4400_gpio_tuner(d, 0)  0) {
+   err(clear tuner gpio failed);
+   return -EIO;
+   }
+   msleep(100);
+   if (cxusb_tt_ct2_4400_gpio_tuner(d, 1)  0) {
+   err(set tuner gpio failed);
+   return -EIO;
+   }
+   msleep(100);
+
+   /* attach frontend */
+   si2168_config.i2c_adapter

[PATCH] si2168: improve scanning performance by setting property 0301 with a value from Windows driver.

2014-07-17 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 0422925..56811e1 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -313,6 +313,13 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   memcpy(cmd.args, \x14\x00\x01\x03\x0c\x00, 6);
+   cmd.wlen = 6;
+   cmd.rlen = 4;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
memcpy(cmd.args, \x85, 1);
cmd.wlen = 1;
cmd.rlen = 1;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] si2157: Use name si2157_ops instead of si2157_tuner_ops (harmonize with si2168)

2014-07-17 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 329004f..4730f69 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -277,7 +277,7 @@ err:
return ret;
 }
 
-static const struct dvb_tuner_ops si2157_tuner_ops = {
+static const struct dvb_tuner_ops si2157_ops = {
.info = {
.name   = Silicon Labs Si2157/Si2158,
.frequency_min  = 11000,
@@ -317,7 +317,7 @@ static int si2157_probe(struct i2c_client *client,
goto err;
 
fe-tuner_priv = s;
-   memcpy(fe-ops.tuner_ops, si2157_tuner_ops,
+   memcpy(fe-ops.tuner_ops, si2157_ops,
sizeof(struct dvb_tuner_ops));
 
i2c_set_clientdata(client, s);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


cxusb: How to add CI support?

2014-07-23 Thread Olli Salonen
Hi everyone,

I'm in need of advice when it comes to the implementation of the
drivers. I recently added support for TechnoTrend CT2-4400 DVB-T2
tuner into the dvb-usb-cxusb module. Now I have gotten another
TechnoTrend device CT2-4650 and it seems this is more or less the same
device as CT2-4400 but with an added CI slot. The CI is realized using
a CIMaX SP2HF chip.

There seems to be support already for the said CIMaX chip, but only in
combination with cx23885 (drivers/media/pci/cx23885/
cimax2.c). This cannot be reused directly in my case. When I look at
the other dvb-usb devices that have CI slot the support for CI has
been implemented directly in the code of the USB device (for example,
pctv452e or az6027).

Of course, an easy way to do it is to reuse a lot of code from the
existing cimax2 and add it in the cxusb. However, I'm not sure if
that's an ok approach. As I'm relatively new to linux kernel coding,
I'd like to ask your recommendation for implementing the CI support
here before the endeavour. Thanks!

Cheers,
-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] si2168: clean logging

2014-08-05 Thread Olli Salonen
Same thing for si2168 as Antti did earlier for tda18212:

There is no need to print module name nor function name as those
are done by kernel logging system when dev_xxx logging is used and
driver is proper I2C driver.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c | 70 +---
 1 file changed, 33 insertions(+), 37 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 8f81d97..59a4218 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -55,8 +55,7 @@ static int si2168_cmd_execute(struct si2168 *s, struct 
si2168_cmd *cmd)
break;
}
 
-   dev_dbg(s-client-dev, %s: cmd execution took %d ms\n,
-   __func__,
+   dev_dbg(s-client-dev, cmd execution took %d ms\n,
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT));
 
@@ -75,7 +74,7 @@ err_mutex_unlock:
 
return 0;
 err:
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -150,12 +149,12 @@ static int si2168_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
c-cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
}
 
-   dev_dbg(s-client-dev, %s: status=%02x args=%*ph\n,
-   __func__, *status, cmd.rlen, cmd.args);
+   dev_dbg(s-client-dev, status=%02x args=%*ph\n,
+   *status, cmd.rlen, cmd.args);
 
return 0;
 err:
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -168,8 +167,8 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
u8 bandwidth, delivery_system;
 
dev_dbg(s-client-dev,
-   %s: delivery_system=%u modulation=%u frequency=%u 
bandwidth_hz=%u symbol_rate=%u inversion=%u\n,
-   __func__, c-delivery_system, c-modulation,
+   delivery_system=%u modulation=%u frequency=%u 
bandwidth_hz=%u symbol_rate=%u inversion=%u\n,
+   c-delivery_system, c-modulation,
c-frequency, c-bandwidth_hz, c-symbol_rate,
c-inversion);
 
@@ -343,7 +342,7 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
 
return 0;
 err:
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -357,7 +356,7 @@ static int si2168_init(struct dvb_frontend *fe)
struct si2168_cmd cmd;
unsigned int chip_id;
 
-   dev_dbg(s-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, \n);
 
memcpy(cmd.args, 
\xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00, 13);
cmd.wlen = 13;
@@ -400,16 +399,16 @@ static int si2168_init(struct dvb_frontend *fe)
break;
default:
dev_err(s-client-dev,
-   %s: unkown chip version Si21%d-%c%c%c\n,
-   KBUILD_MODNAME, cmd.args[2], cmd.args[1],
+   unknown chip version Si21%d-%c%c%c\n,
+   cmd.args[2], cmd.args[1],
cmd.args[3], cmd.args[4]);
ret = -EINVAL;
goto err;
}
 
/* cold state - try to download firmware */
-   dev_info(s-client-dev, %s: found a '%s' in cold state\n,
-   KBUILD_MODNAME, si2168_ops.info.name);
+   dev_info(s-client-dev, found a '%s' in cold state\n,
+   si2168_ops.info.name);
 
/* request the firmware, this will block and timeout */
ret = request_firmware(fw, fw_file, s-client-dev);
@@ -422,18 +421,18 @@ static int si2168_init(struct dvb_frontend *fe)
 
if (ret == 0) {
dev_notice(s-client-dev,
-   %s: please install firmware file 
'%s'\n,
-   KBUILD_MODNAME, SI2168_B40_FIRMWARE);
+   please install firmware file '%s'\n,
+   SI2168_B40_FIRMWARE);
} else {
dev_err(s-client-dev,
-   %s: firmware file '%s' not found\n,
-   KBUILD_MODNAME, fw_file);
+   firmware file '%s' not found\n,
+   fw_file);
goto err;
}
}
 
-   dev_info(s-client-dev, %s: downloading firmware from file '%s'\n,
-   KBUILD_MODNAME, fw_file);
+   dev_info(s-client-dev

[PATCH] si2157: clean logging

2014-08-05 Thread Olli Salonen
Same thing for si2157 as Antti did earlier for tda18212:

There is no need to print module name nor function name as those
are done by kernel logging system when dev_xxx logging is used and
driver is proper I2C driver.

While here, fix a typo (unknown) in si2157_init.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 52 +--
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 6c53edb..2281b7d 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -55,8 +55,7 @@ static int si2157_cmd_execute(struct si2157 *s, struct 
si2157_cmd *cmd)
break;
}
 
-   dev_dbg(s-client-dev, %s: cmd execution took %d ms\n,
-   __func__,
+   dev_dbg(s-client-dev, cmd execution took %d ms\n,
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT));
 
@@ -75,7 +74,7 @@ err_mutex_unlock:
 
return 0;
 err:
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -88,7 +87,7 @@ static int si2157_init(struct dvb_frontend *fe)
u8 *fw_file;
unsigned int chip_id;
 
-   dev_dbg(s-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, \n);
 
/* configure? */
memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
@@ -121,35 +120,35 @@ static int si2157_init(struct dvb_frontend *fe)
break;
default:
dev_err(s-client-dev,
-   %s: unkown chip version Si21%d-%c%c%c\n,
-   KBUILD_MODNAME, cmd.args[2], cmd.args[1],
+   unknown chip version Si21%d-%c%c%c\n,
+   cmd.args[2], cmd.args[1],
cmd.args[3], cmd.args[4]);
ret = -EINVAL;
goto err;
}
 
/* cold state - try to download firmware */
-   dev_info(s-client-dev, %s: found a '%s' in cold state\n,
-   KBUILD_MODNAME, si2157_ops.info.name);
+   dev_info(s-client-dev, found a '%s' in cold state\n,
+   si2157_ops.info.name);
 
/* request the firmware, this will block and timeout */
ret = request_firmware(fw, fw_file, s-client-dev);
if (ret) {
-   dev_err(s-client-dev, %s: firmware file '%s' not found\n,
-   KBUILD_MODNAME, fw_file);
+   dev_err(s-client-dev, firmware file '%s' not found\n,
+   fw_file);
goto err;
}
 
/* firmware should be n chunks of 17 bytes */
if (fw-size % 17 != 0) {
-   dev_err(s-client-dev, %s: firmware file '%s' is invalid\n,
-   KBUILD_MODNAME, fw_file);
+   dev_err(s-client-dev, firmware file '%s' is invalid\n,
+   fw_file);
ret = -EINVAL;
goto err;
}
 
-   dev_info(s-client-dev, %s: downloading firmware from file '%s'\n,
-   KBUILD_MODNAME, fw_file);
+   dev_info(s-client-dev, downloading firmware from file '%s'\n,
+   fw_file);
 
for (remaining = fw-size; remaining  0; remaining -= 17) {
len = fw-data[fw-size - remaining];
@@ -159,8 +158,8 @@ static int si2157_init(struct dvb_frontend *fe)
ret = si2157_cmd_execute(s, cmd);
if (ret) {
dev_err(s-client-dev,
-   %s: firmware download failed=%d\n,
-   KBUILD_MODNAME, ret);
+   firmware download failed=%d\n,
+   ret);
goto err;
}
}
@@ -184,7 +183,7 @@ err:
if (fw)
release_firmware(fw);
 
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -194,7 +193,7 @@ static int si2157_sleep(struct dvb_frontend *fe)
int ret;
struct si2157_cmd cmd;
 
-   dev_dbg(s-client-dev, %s:\n, __func__);
+   dev_dbg(s-client-dev, \n);
 
s-active = false;
 
@@ -207,7 +206,7 @@ static int si2157_sleep(struct dvb_frontend *fe)
 
return 0;
 err:
-   dev_dbg(s-client-dev, %s: failed=%d\n, __func__, ret);
+   dev_dbg(s-client-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -220,8 +219,8 @@ static int si2157_set_params(struct dvb_frontend *fe)
u8 bandwidth, delivery_system;
 
dev_dbg(s-client-dev,
-   %s

[PATCH 3/3] cxusb: Add support for TechnoTrend TT-connect CT2-4650 CI

2014-08-06 Thread Olli Salonen
TechnoTrend TT-connect CT2-4650 CI is an USB DVB-T2/C tuner with the
following components:

 USB interface: Cypress CY7C68013A-56LTXC
 Demodulator: Silicon Labs Si2168-A20
 Tuner: Silicon Labs Si2158-A20
 CI chip: CIMaX SP2HF

The firmware for the tuner is the same as for TechnoTrend TT-TVStick CT2-4400. 
See
https://www.mail-archive.com/linux-media@vger.kernel.org/msg76944.html

The demodulator needs a firmware that can be extracted from the Windows drivers.
File ttConnect4650_64.sys should be extracted from
http://www.tt-downloads.de/bda-treiber_4.1.0.4.zip (MD5 sum below).

3464bfc37a47b4032568718bacba23fb  ttConnect4650_64.sys

Then the firmware can be extracted:
dd if=ttConnect4650_64.sys ibs=1 skip=273376 count=6424 
of=dvb-demod-si2168-a20-01.fw

The SP2 CI module requires a definition of a function cxusb_tt_ct2_4650_ci_ctrl 
that
is passed on to the SP2 driver and called back for CAM operations.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb/Kconfig |  1 +
 drivers/media/usb/dvb-usb/cxusb.c | 92 ++-
 drivers/media/usb/dvb-usb/cxusb.h |  4 ++
 3 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/Kconfig 
b/drivers/media/usb/dvb-usb/Kconfig
index 10aef21..87deb55 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -118,6 +118,7 @@ config DVB_USB_CXUSB
select DVB_ATBM8830 if MEDIA_SUBDRV_AUTOSELECT
select DVB_LGS8GXX if MEDIA_SUBDRV_AUTOSELECT
select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SP2 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_SIMPLE if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_XC2028 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_MXL5005S if MEDIA_SUBDRV_AUTOSELECT
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index 16bc579..499d76d 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -44,6 +44,7 @@
 #include atbm8830.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 
 /* Max transfer size done by I2C transfer functions */
 #define MAX_XFER_SIZE  80
@@ -672,6 +673,37 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
{ 0x0025, KEY_POWER },
 };
 
+static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr,
+   u8 data, int *mem)
+{
+   struct dvb_usb_device *d = priv;
+   u8 wbuf[3];
+   u8 rbuf[2];
+   int ret;
+
+   wbuf[0] = (addr  8)  0xff;
+   wbuf[1] = addr  0xff;
+
+   if (read) {
+   ret = cxusb_ctrl_msg(d, CMD_SP2_CI_READ, wbuf, 2, rbuf, 2);
+   } else {
+   wbuf[2] = data;
+   ret = cxusb_ctrl_msg(d, CMD_SP2_CI_WRITE, wbuf, 3, rbuf, 1);
+   }
+
+   if (ret)
+   goto err;
+
+   if (read)
+   *mem = rbuf[1];
+
+   return 0;
+err:
+   deb_info(%s: ci usb write returned %d\n, __func__, ret);
+   return ret;
+
+}
+
 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
 {
static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
@@ -1350,9 +1382,12 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
struct i2c_adapter *adapter;
struct i2c_client *client_demod;
struct i2c_client *client_tuner;
+   struct i2c_client *client_ci;
struct i2c_board_info info;
struct si2168_config si2168_config;
struct si2157_config si2157_config;
+   struct sp2_config sp2_config;
+   u8 o[2], i;
 
/* reset the tuner */
if (cxusb_tt_ct2_4400_gpio_tuner(d, 0)  0) {
@@ -1408,6 +1443,48 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
 
st-i2c_client_tuner = client_tuner;
 
+   /* initialize CI */
+   if (d-udev-descriptor.idProduct ==
+   USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) {
+
+   memcpy(o, \xc0\x01, 2);
+   cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, i, 1);
+   msleep(100);
+
+   memcpy(o, \xc0\x00, 2);
+   cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, i, 1);
+   msleep(100);
+
+   memset(sp2_config, 0, sizeof(sp2_config));
+   sp2_config.dvb_adap = adap-dvb_adap;
+   sp2_config.priv = d;
+   sp2_config.ci_control = cxusb_tt_ct2_4650_ci_ctrl;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, sp2, I2C_NAME_SIZE);
+   info.addr = 0x40;
+   info.platform_data = sp2_config;
+   request_module(info.type);
+   client_ci = i2c_new_device(d-i2c_adap, info);
+   if (client_ci == NULL || client_ci-dev.driver == NULL) {
+   module_put(client_tuner-dev.driver-owner);
+   i2c_unregister_device(client_tuner);
+   module_put

[PATCH 2/3] Add USB ID for TechnoTrend TT-connect CT2-4650 CI

2014-08-06 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-core/dvb-usb-ids.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 5135a09..b7a9b98 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -244,6 +244,7 @@
 #define USB_PID_TECHNOTREND_CONNECT_S2400   0x3006
 #define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
 #define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
+#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI0x3012
 #define USB_PID_TECHNOTREND_TVSTICK_CT2_4400   0x3014
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY   0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] sp2: Add I2C driver for CIMaX SP2 common interface module

2014-08-06 Thread Olli Salonen
Driver for the CIMaX SP2 common interface chip. It is very much based on
the existing cimax2 driver for cx23885, but should be more reusable. The
product has been sold with name Atmel T90FJR as well and the data sheets
for that chip seem to be publicly available.

It seems that the USB device that I have and the cx23885 based devices will
need to interact differently with the chip for the CAM operations. Thus
there is one callback function that is passed on to the sp2 driver
(see function sp2_ci_op_cam for that one).

IRQ functionality is not included currently (not needed by USB devices
and I don't have a PCIe device for development).

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/Makefile   |   1 +
 drivers/media/dvb-frontends/sp2.c  | 411 +
 drivers/media/dvb-frontends/sp2.h  |  54 +
 drivers/media/dvb-frontends/sp2_priv.h |  49 
 4 files changed, 515 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/sp2.c
 create mode 100644 drivers/media/dvb-frontends/sp2.h
 create mode 100644 drivers/media/dvb-frontends/sp2_priv.h

diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index edf103d..3498b95 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -107,6 +107,7 @@ obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
 obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
+obj-$(CONFIG_DVB_SP2) += sp2.o
 obj-$(CONFIG_DVB_TDA10071) += tda10071.o
 obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
 obj-$(CONFIG_DVB_RTL2832) += rtl2832.o
diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
new file mode 100644
index 000..c1b4d7e
--- /dev/null
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -0,0 +1,411 @@
+/*
+ * CIMaX SP2/SP2HF (Atmel T90FJR) CI driver
+ *
+ * Copyright (C) 2014 Olli Salonen olli.salo...@iki.fi
+ *
+ * Heavily based on CIMax2(R) SP2 driver in conjunction with NetUp Dual
+ * DVB-S2 CI card (cimax2) with following copyrights:
+ *
+ *  Copyright (C) 2009 NetUP Inc.
+ *  Copyright (C) 2009 Igor M. Liplianin liplia...@netup.ru
+ *  Copyright (C) 2009 Abylay Ospan aos...@netup.ru
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *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 sp2_priv.h
+
+static int sp2_read_i2c(struct sp2 *s, u8 reg, u8 *buf, int len)
+{
+   int ret;
+   struct i2c_client *client = s-client;
+   struct i2c_adapter *adap = client-adapter;
+   struct i2c_msg msg[] = {
+   {
+   .addr = client-addr,
+   .flags = 0,
+   .buf = reg,
+   .len = 1
+   }, {
+   .addr = client-addr,
+   .flags  = I2C_M_RD,
+   .buf = buf,
+   .len = len
+   }
+   };
+
+   ret = i2c_transfer(adap, msg, 2);
+
+   if (ret != 2) {
+   dev_err(client-dev, i2c read error, reg = 0x%02x, status = 
%d\n,
+   reg, ret);
+   return -1;
+   }
+
+   dev_dbg(s-client-dev, addr=0x%04x, reg = 0x%02x, data = %02x\n,
+   client-addr, reg, buf[0]);
+
+   return 0;
+}
+
+static int sp2_write_i2c(struct sp2 *s, u8 reg, u8 *buf, int len)
+{
+   int ret;
+   u8 buffer[35];
+   struct i2c_client *client = s-client;
+   struct i2c_adapter *adap = client-adapter;
+   struct i2c_msg msg = {
+   .addr = client-addr,
+   .flags = 0,
+   .buf = buffer[0],
+   .len = len + 1
+   };
+
+   if ((len + 1)  sizeof(buffer)) {
+   dev_err(client-dev, i2c wr reg=%02x: len=%d is too big!\n,
+   reg, len);
+   return -EINVAL;
+   }
+
+   buffer[0] = reg;
+   memcpy(buffer[1], buf, len);
+
+   ret = i2c_transfer(adap, msg, 1);
+
+   if (ret != 1) {
+   dev_err(client-dev, i2c write error, reg = 0x%02x, status = 
%d\n,
+   reg, ret);
+   return -1;
+   }
+
+   return 0;
+}
+
+static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot, u8 acs,
+   u8 read, int addr, u8 data)
+{
+   struct sp2 *s = en50221-data;
+   u8 store;
+   int mem, ret;
+   int (*ci_op_cam)(void*, u8, int, u8, int*) = s-ci_control

[PATCH] sp2: Add SP2 entry to Kconfig

2014-08-06 Thread Olli Salonen
Option DVB_SP2 must be in Kconfig as well. This patch should be applied 
together with patch 25206 that was submitted earlier today.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index fe0ddcc..c38c936 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -720,6 +720,13 @@ config DVB_A8293
depends on DVB_CORE  I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
 
+config DVB_SP2
+   tristate CIMaX SP2
+   depends on DVB_CORE  I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ CIMaX SP2/SP2HF Common Interface module.
+
 config DVB_LGS8GL5
tristate Silicon Legend LGS-8GL5 demodulator (OFDM)
depends on DVB_CORE  I2C
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] sp2: Add I2C driver for CIMaX SP2 common interface module

2014-08-07 Thread Olli Salonen
Thank you Antti for the review. I'll submit another version of the
patch in the coming days.

Cheers,
-olli

On 7 August 2014 19:28, Antti Palosaari cr...@iki.fi wrote:
 Reviewed-by: Antti Palosaari cr...@iki.fi

 None of those findings are critical. However I hope you double check and fix
 if there is any relevant enough.

 regards
 Antti

 --
 http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driver for DVBSky dvb-s2 box

2014-08-07 Thread Olli Salonen
Hi Max,

nibble.max nibble.max at gmail.com writes:
 diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig
b/drivers/media/usb/dvb-usb-v2/Kconfig
 index 66645b0..8107c8d 100644
 --- a/drivers/media/usb/dvb-usb-v2/Kconfig
 +++ b/drivers/media/usb/dvb-usb-v2/Kconfig
  at  at  -141,3 +141,9  at  at  config DVB_USB_RTL28XXU
   help
 Say Y here to support the Realtek RTL28xxU DVB USB receiver.
 
 +config DVB_USB_DVBSKY
 + tristate DVBSky USB support
 + depends on DVB_USB_V2
 + select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
 + help
 +   Say Y here to support the USB receivers from DVBSky.

Shouldn't the MEDIA_TUNER_M88TS2022 also be selected in Kconfig?

Cheers,
-olli



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] cxusb: Add read_mac_address for TT CT2-4400 and CT2-4650

2014-08-08 Thread Olli Salonen
Read MAC address from the EEPROM.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb/cxusb.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index c3a44c7..6abfd6b 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -673,6 +673,41 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
{ 0x0025, KEY_POWER },
 };
 
+static int cxusb_tt_ct2_4400_read_mac_address(struct dvb_usb_device *d, u8 
mac[6])
+{
+   u8 wbuf[2];
+   u8 rbuf[6];
+   int ret;
+   struct i2c_msg msg[] = {
+   {
+   .addr = 0x51,
+   .flags = 0,
+   .buf = wbuf,
+   .len = 2,
+   }, {
+   .addr = 0x51,
+   .flags = I2C_M_RD,
+   .buf = rbuf,
+   .len = 6,
+   }
+   };
+
+   wbuf[0] = 0x1e;
+   wbuf[1] = 0x00;
+   ret = cxusb_i2c_xfer(d-i2c_adap, msg, 2);
+
+   if (ret == 2) {
+   memcpy(mac, rbuf, 6);
+   return 0;
+   } else {
+   if (ret  0)
+   return ret;
+   else
+   return -EIO;
+   }
+   }
+}
+
 static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr,
u8 data, int *mem)
 {
@@ -2315,6 +2350,8 @@ static struct dvb_usb_device_properties 
cxusb_tt_ct2_4400_properties = {
.size_of_priv = sizeof(struct cxusb_state),
 
.num_adapters = 1,
+   .read_mac_address = cxusb_tt_ct2_4400_read_mac_address,
+
.adapter = {
{
.num_frontends = 1,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 1/4] sp2: Add I2C driver for CIMaX SP2 common interface module

2014-08-08 Thread Olli Salonen
Driver for the CIMaX SP2 common interface chip. It is very much based on
the existing cimax2 driver for cx23885, but should be more reusable. The
product has been sold with name Atmel T90FJR as well and the data sheets
for that chip seem to be publicly available.

It seems that the USB device that I have and the cx23885 based devices will
need to interact differently with the chip for the CAM operations. Thus
there is one callback function that is passed on to the sp2 driver
(see function sp2_ci_op_cam for that one).

IRQ functionality is not included currently (not needed by USB devices
and I don't have a PCIe device for development).

This is the second version of the patch series after review by Antti
Palosaari.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/Kconfig|   7 +
 drivers/media/dvb-frontends/Makefile   |   1 +
 drivers/media/dvb-frontends/sp2.c  | 441 +
 drivers/media/dvb-frontends/sp2.h  |  53 
 drivers/media/dvb-frontends/sp2_priv.h |  50 
 5 files changed, 552 insertions(+)
 create mode 100644 drivers/media/dvb-frontends/sp2.c
 create mode 100644 drivers/media/dvb-frontends/sp2.h
 create mode 100644 drivers/media/dvb-frontends/sp2_priv.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index fe0ddcc..c38c936 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -720,6 +720,13 @@ config DVB_A8293
depends on DVB_CORE  I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
 
+config DVB_SP2
+   tristate CIMaX SP2
+   depends on DVB_CORE  I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ CIMaX SP2/SP2HF Common Interface module.
+
 config DVB_LGS8GL5
tristate Silicon Legend LGS-8GL5 demodulator (OFDM)
depends on DVB_CORE  I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index edf103d..3498b95 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -107,6 +107,7 @@ obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
 obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
+obj-$(CONFIG_DVB_SP2) += sp2.o
 obj-$(CONFIG_DVB_TDA10071) += tda10071.o
 obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
 obj-$(CONFIG_DVB_RTL2832) += rtl2832.o
diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
new file mode 100644
index 000..9b684d5
--- /dev/null
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -0,0 +1,441 @@
+/*
+ * CIMaX SP2/SP2HF (Atmel T90FJR) CI driver
+ *
+ * Copyright (C) 2014 Olli Salonen olli.salo...@iki.fi
+ *
+ * Heavily based on CIMax2(R) SP2 driver in conjunction with NetUp Dual
+ * DVB-S2 CI card (cimax2) with following copyrights:
+ *
+ *  Copyright (C) 2009 NetUP Inc.
+ *  Copyright (C) 2009 Igor M. Liplianin liplia...@netup.ru
+ *  Copyright (C) 2009 Abylay Ospan aos...@netup.ru
+ *
+ *This program is free software; you can redistribute it and/or modify
+ *it under the terms of the GNU General Public License as published by
+ *the Free Software Foundation; either version 2 of the License, or
+ *(at your option) any later version.
+ *
+ *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 sp2_priv.h
+
+static int sp2_read_i2c(struct sp2 *s, u8 reg, u8 *buf, int len)
+{
+   int ret;
+   struct i2c_client *client = s-client;
+   struct i2c_adapter *adap = client-adapter;
+   struct i2c_msg msg[] = {
+   {
+   .addr = client-addr,
+   .flags = 0,
+   .buf = reg,
+   .len = 1
+   }, {
+   .addr = client-addr,
+   .flags  = I2C_M_RD,
+   .buf = buf,
+   .len = len
+   }
+   };
+
+   ret = i2c_transfer(adap, msg, 2);
+
+   if (ret != 2) {
+   dev_err(client-dev, i2c read error, reg = 0x%02x, status = 
%d\n,
+   reg, ret);
+   if (ret  0)
+   return ret;
+   else
+   return -EIO;
+   }
+
+   dev_dbg(s-client-dev, addr=0x%04x, reg = 0x%02x, data = %02x\n,
+   client-addr, reg, buf[0]);
+
+   return 0;
+}
+
+static int sp2_write_i2c(struct sp2 *s, u8 reg, u8 *buf, int len)
+{
+   int ret;
+   u8 buffer[35];
+   struct i2c_client *client = s-client;
+   struct i2c_adapter *adap = client-adapter;
+   struct i2c_msg msg = {
+   .addr = client-addr,
+   .flags = 0,
+   .buf = buffer[0

[PATCHv2 3/4] cxusb: Add support for TechnoTrend TT-connect CT2-4650 CI

2014-08-08 Thread Olli Salonen
TechnoTrend TT-connect CT2-4650 CI (0b48:3012) is an USB DVB-T2/C tuner with
the following components:

 USB interface: Cypress CY7C68013A-56LTXC
 Demodulator: Silicon Labs Si2168-A20
 Tuner: Silicon Labs Si2158-A20
 CI chip: CIMaX SP2HF

The firmware for the tuner is the same as for TechnoTrend TT-TVStick CT2-4400.
See https://www.mail-archive.com/linux-media@vger.kernel.org/msg76944.html

The demodulator needs a firmware that can be extracted from the Windows 
drivers. 
File ttConnect4650_64.sys should be extracted from 
http://www.tt-downloads.de/bda-treiber_4.1.0.4.zip (MD5 sum below).

3464bfc37a47b4032568718bacba23fb  ttConnect4650_64.sys

Then the firmware can be extracted:
dd if=ttConnect4650_64.sys ibs=1 skip=273376 count=6424 
of=dvb-demod-si2168-a20-01.fw

The SP2 CI module requires a definition of a function cxusb_tt_ct2_4650_ci_ctrl
that is passed on to the SP2 driver and called back for CAM operations.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb/Kconfig |  2 +-
 drivers/media/usb/dvb-usb/cxusb.c | 92 ++-
 drivers/media/usb/dvb-usb/cxusb.h |  4 ++
 3 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/Kconfig 
b/drivers/media/usb/dvb-usb/Kconfig
index 10aef21..41d3eb9 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -130,7 +130,7 @@ config DVB_USB_CXUSB
 
  Medion MD95700 hybrid USB2.0 device.
  DViCO FusionHDTV (Bluebird) USB2.0 devices
- TechnoTrend TVStick CT2-4400
+ TechnoTrend TVStick CT2-4400 and CT2-4650 CI devices
 
 config DVB_USB_M920X
tristate Uli m920x DVB-T USB2.0 support
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index 16bc579..c3a44c7 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -44,6 +44,7 @@
 #include atbm8830.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 
 /* Max transfer size done by I2C transfer functions */
 #define MAX_XFER_SIZE  80
@@ -672,6 +673,37 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
{ 0x0025, KEY_POWER },
 };
 
+static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr,
+   u8 data, int *mem)
+{
+   struct dvb_usb_device *d = priv;
+   u8 wbuf[3];
+   u8 rbuf[2];
+   int ret;
+
+   wbuf[0] = (addr  8)  0xff;
+   wbuf[1] = addr  0xff;
+
+   if (read) {
+   ret = cxusb_ctrl_msg(d, CMD_SP2_CI_READ, wbuf, 2, rbuf, 2);
+   } else {
+   wbuf[2] = data;
+   ret = cxusb_ctrl_msg(d, CMD_SP2_CI_WRITE, wbuf, 3, rbuf, 1);
+   }
+
+   if (ret)
+   goto err;
+
+   if (read)
+   *mem = rbuf[1];
+
+   return 0;
+err:
+   deb_info(%s: ci usb write returned %d\n, __func__, ret);
+   return ret;
+
+}
+
 static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
 {
static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
@@ -1350,9 +1382,12 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
struct i2c_adapter *adapter;
struct i2c_client *client_demod;
struct i2c_client *client_tuner;
+   struct i2c_client *client_ci;
struct i2c_board_info info;
struct si2168_config si2168_config;
struct si2157_config si2157_config;
+   struct sp2_config sp2_config;
+   u8 o[2], i;
 
/* reset the tuner */
if (cxusb_tt_ct2_4400_gpio_tuner(d, 0)  0) {
@@ -1408,6 +1443,48 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
 
st-i2c_client_tuner = client_tuner;
 
+   /* initialize CI */
+   if (d-udev-descriptor.idProduct ==
+   USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI) {
+
+   memcpy(o, \xc0\x01, 2);
+   cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, i, 1);
+   msleep(100);
+
+   memcpy(o, \xc0\x00, 2);
+   cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, i, 1);
+   msleep(100);
+
+   memset(sp2_config, 0, sizeof(sp2_config));
+   sp2_config.dvb_adap = adap-dvb_adap;
+   sp2_config.priv = d;
+   sp2_config.ci_control = cxusb_tt_ct2_4650_ci_ctrl;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, sp2, I2C_NAME_SIZE);
+   info.addr = 0x40;
+   info.platform_data = sp2_config;
+   request_module(info.type);
+   client_ci = i2c_new_device(d-i2c_adap, info);
+   if (client_ci == NULL || client_ci-dev.driver == NULL) {
+   module_put(client_tuner-dev.driver-owner);
+   i2c_unregister_device(client_tuner);
+   module_put(client_demod-dev.driver-owner);
+   i2c_unregister_device(client_demod

[PATCHv2 2/4] Add USB ID for TechnoTrend TT-connect CT2-4650 CI

2014-08-08 Thread Olli Salonen
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-core/dvb-usb-ids.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index 5135a09..b7a9b98 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -244,6 +244,7 @@
 #define USB_PID_TECHNOTREND_CONNECT_S2400   0x3006
 #define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM 0x3009
 #define USB_PID_TECHNOTREND_CONNECT_CT3650 0x300d
+#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI0x3012
 #define USB_PID_TECHNOTREND_TVSTICK_CT2_4400   0x3014
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY   0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2 0x0081
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] em28xx: add ts mode setting for PCTV 461e

2014-08-11 Thread Olli Salonen
TS mode must be set in the existing PCTV 461e driver.

Signed-off-by: Olli Salonen olli.salo...@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

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] cx23855: add frontend set voltage function into state

2014-08-11 Thread Olli Salonen
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.salo...@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

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] si2168: add ts_mode setting and move to si2168_init

2014-08-11 Thread Olli Salonen
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.salo...@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

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] cxusb: add ts mode setting for TechnoTrend CT2-4400

2014-08-11 Thread Olli Salonen
TS mode must be set in the existing TechnoTrend CT2-4400 driver.

Signed-off-by: Olli Salonen olli.salo...@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

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] cx23885: add i2c client handling into dvb_unregister and state

2014-08-11 Thread Olli Salonen
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.salo...@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

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] cx23855: add support for DVBSky T9580 DVB-C/T2/S2 tuner

2014-08-11 Thread Olli Salonen
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@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.salo...@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, 0x0037);
+   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

Re: [PATCH 2/6] em28xx: add ts mode setting for PCTV 461e

2014-08-13 Thread Olli Salonen
Indeed, the patch is correct, but the description should say:

em28xx: add ts mode setting for PCTV 292e
TS mode must be set in the existing PCTV 292e driver.

Thanks for your reviews!

On 13 August 2014 02:23, Antti Palosaari cr...@iki.fi wrote:
 Acked-by: Antti Palosaari cr...@iki.fi
 Reviewed-by: Antti Palosaari cr...@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.salo...@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/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] si2157: Add support for delivery system SYS_ATSC

2014-08-16 Thread Olli Salonen
Set the property for delivery system also in case of SYS_ATSC. This 
behaviour is observed in the sniffs taken with Hauppauge HVR-955Q 
Windows driver.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 6c53edb..3b86d59 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -239,6 +239,9 @@ static int si2157_set_params(struct dvb_frontend *fe)
bandwidth = 0x0f;
 
switch (c-delivery_system) {
+   case SYS_ATSC:
+   delivery_system = 0x00;
+   break;
case SYS_DVBT:
case SYS_DVBT2: /* it seems DVB-T and DVB-T2 both are 0x20 here */
delivery_system = 0x20;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2] cxusb: Add read_mac_address for TT CT2-4400 and CT2-4650

2014-08-21 Thread Olli Salonen
Read MAC address from the EEPROM. This version two corrects a flaw in the 
result code returning that did exist in the first version.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb/cxusb.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index c3a44c7..f631955 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -673,6 +673,39 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
{ 0x0025, KEY_POWER },
 };
 
+static int cxusb_tt_ct2_4400_read_mac_address(struct dvb_usb_device *d, u8 
mac[6])
+{
+   u8 wbuf[2];
+   u8 rbuf[6];
+   int ret;
+   struct i2c_msg msg[] = {
+   {
+   .addr = 0x51,
+   .flags = 0,
+   .buf = wbuf,
+   .len = 2,
+   }, {
+   .addr = 0x51,
+   .flags = I2C_M_RD,
+   .buf = rbuf,
+   .len = 6,
+   }
+   };
+
+   wbuf[0] = 0x1e;
+   wbuf[1] = 0x00;
+   ret = cxusb_i2c_xfer(d-i2c_adap, msg, 2);
+
+   if (ret == 2) {
+   memcpy(mac, rbuf, 6);
+   return 0;
+   } else {
+   if (ret  0)
+   return ret;
+   return -EIO;
+   }
+}
+
 static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr,
u8 data, int *mem)
 {
@@ -2315,6 +2348,8 @@ static struct dvb_usb_device_properties 
cxusb_tt_ct2_4400_properties = {
.size_of_priv = sizeof(struct cxusb_state),
 
.num_adapters = 1,
+   .read_mac_address = cxusb_tt_ct2_4400_read_mac_address,
+
.adapter = {
{
.num_frontends = 1,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] MAINTAINERS: add sp2 entry

2014-08-22 Thread Olli Salonen
Add a maintainer for the new CIMaX SP2 driver.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 MAINTAINERS |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4cdf24c..6139b66 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8451,6 +8451,14 @@ F:   include/sound/dmaengine_pcm.h
 F: sound/core/pcm_dmaengine.c
 F: sound/soc/soc-generic-dmaengine-pcm.c
 
+SP2 MEDIA DRIVER
+M: Olli Salonen olli.salo...@iki.fi
+L: linux-media@vger.kernel.org
+W: http://linuxtv.org/
+Q: http://patchwork.linuxtv.org/project/linux-media/list/
+S: Maintained
+F: drivers/media/dvb-frontends/sp2*
+
 SPARC + UltraSPARC (sparc/sparc64)
 M: David S. Miller da...@davemloft.net
 L: sparcli...@vger.kernel.org
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] si2157: avoid firmware loading if it has been loaded previously

2014-08-25 Thread Olli Salonen
Add a variable into state to keep track if firmware has been loaded or not. 
Skip firmware loading in case it is already loaded (resume from sleep).

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 11 +--
 drivers/media/tuners/si2157_priv.h |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index c84f7b8..5901484 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -89,7 +89,10 @@ static int si2157_init(struct dvb_frontend *fe)
 
dev_dbg(s-client-dev, \n);
 
-   /* configure? */
+   if (s-fw_loaded)
+   goto warm;
+
+   /* power up */
memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
cmd.wlen = 15;
cmd.rlen = 1;
@@ -176,9 +179,12 @@ skip_fw_download:
if (ret)
goto err;
 
-   s-active = true;
+   s-fw_loaded = true;
 
+warm:
+   s-active = true;
return 0;
+
 err:
if (fw)
release_firmware(fw);
@@ -320,6 +326,7 @@ static int si2157_probe(struct i2c_client *client,
s-client = client;
s-fe = cfg-fe;
s-inversion = cfg-inversion;
+   s-fw_loaded = false;
mutex_init(s-i2c_mutex);
 
/* check if the tuner is there */
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index 3ddab5e..4080a57 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -26,6 +26,7 @@ struct si2157 {
struct i2c_client *client;
struct dvb_frontend *fe;
bool active;
+   bool fw_loaded;
bool inversion;
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] si2157: change command for sleep

2014-08-25 Thread Olli Salonen
Instead of sending command 13 to the tuner, send command 16 when sleeping. This 
behaviour is observed when using manufacturer provided binary-only Linux driver 
for TechnoTrend CT2-4400 (Windows driver does not do power management).

The issue with command 13 is that firmware loading is necessary after that. 
This is not an issue with tuners that do not require firmware, but resuming 
from sleep on an Si2158 takes noticeable time as firmware is loaded on resume.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index efb5cce..c84f7b8 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -197,9 +197,10 @@ static int si2157_sleep(struct dvb_frontend *fe)
 
s-active = false;
 
-   memcpy(cmd.args, \x13, 1);
-   cmd.wlen = 1;
-   cmd.rlen = 0;
+   /* standby */
+   memcpy(cmd.args, \x16\x00, 2);
+   cmd.wlen = 2;
+   cmd.rlen = 1;
ret = si2157_cmd_execute(s, cmd);
if (ret)
goto err;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] si2168: avoid firmware loading if it has been loaded previously

2014-08-25 Thread Olli Salonen
Add a variable to keep track if firmware is loaded or not and skip parts of the 
initialization if fw is already loaded. Resume from sleep with a different 
command compared to initial power up and run command 85 after resume command. 
This behaviour is observed when using manufacturer provided binary-only si2168 
driver for TechnoTrend CT2-4400.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c  | 31 ---
 drivers/media/dvb-frontends/si2168_priv.h |  1 +
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 55a4212..a0797fd 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -363,6 +363,7 @@ static int si2168_init(struct dvb_frontend *fe)
 
dev_dbg(s-client-dev, \n);
 
+   /* initialize */
memcpy(cmd.args, 
\xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00, 13);
cmd.wlen = 13;
cmd.rlen = 0;
@@ -370,6 +371,26 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   if (s-fw_loaded) {
+   /* resume */
+   memcpy(cmd.args, \xc0\x06\x08\x0f\x00\x20\x21\x01, 8);
+   cmd.wlen = 8;
+   cmd.rlen = 1;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   memcpy(cmd.args, \x85, 1);
+   cmd.wlen = 1;
+   cmd.rlen = 1;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   goto warm;
+   }
+
+   /* power up */
memcpy(cmd.args, \xc0\x06\x01\x0f\x00\x20\x20\x01, 8);
cmd.wlen = 8;
cmd.rlen = 1;
@@ -466,9 +487,6 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   dev_info(s-client-dev, found a '%s' in warm state\n,
-   si2168_ops.info.name);
-
/* set ts mode */
memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
cmd.args[4] |= s-ts_mode;
@@ -478,6 +496,12 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   s-fw_loaded = true;
+
+warm:
+   dev_info(s-client-dev, found a '%s' in warm state\n,
+   si2168_ops.info.name);
+
s-active = true;
 
return 0;
@@ -645,6 +669,7 @@ static int si2168_probe(struct i2c_client *client,
*config-i2c_adapter = s-adapter;
*config-fe = s-fe;
s-ts_mode = config-ts_mode;
+   s-fw_loaded = false;
 
i2c_set_clientdata(client, s);
 
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 0f83284..e13983e 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;
+   bool fw_loaded;
u8 ts_mode;
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] si2168: avoid firmware loading if it has been loaded previously

2014-09-05 Thread Olli Salonen
Moro,

I'll test it once more when testing the si2157 sleep hack you
posted. Though I remember that the command 85 seemed to be the magic
trick that finally made it work - I agree it sounds a bit strange
considering it's run later on anyway. The proprietary driver seems to
do a command 85 after wake up, but of course that's not a guarantee of
anything.

My sniff using the proprietary driver is here:
http://trsqr.net/olli/ct2-4400/ct2-4400-wakeup-tune-sleep.txt

Cheers,
-olli

On 5 September 2014 11:36, Antti Palosaari cr...@iki.fi wrote:
 Moikka
 Did you really need command 85 here? It will be given later in any case. For
 my Si2168 B40 there was no need for it.

 regards
 Antti

 On 08/25/2014 09:07 PM, Olli Salonen wrote:

 Add a variable to keep track if firmware is loaded or not and skip parts
 of the
 initialization if fw is already loaded. Resume from sleep with a different
 command compared to initial power up and run command 85 after resume
 command.
 This behaviour is observed when using manufacturer provided binary-only
 si2168
 driver for TechnoTrend CT2-4400.

 Signed-off-by: Olli Salonen olli.salo...@iki.fi
 ---
   drivers/media/dvb-frontends/si2168.c  | 31
 ---
   drivers/media/dvb-frontends/si2168_priv.h |  1 +
   2 files changed, 29 insertions(+), 3 deletions(-)

 diff --git a/drivers/media/dvb-frontends/si2168.c
 b/drivers/media/dvb-frontends/si2168.c
 index 55a4212..a0797fd 100644
 --- a/drivers/media/dvb-frontends/si2168.c
 +++ b/drivers/media/dvb-frontends/si2168.c
 @@ -363,6 +363,7 @@ static int si2168_init(struct dvb_frontend *fe)

 dev_dbg(s-client-dev, \n);

 +   /* initialize */
 memcpy(cmd.args,
 \xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00, 13);
 cmd.wlen = 13;
 cmd.rlen = 0;
 @@ -370,6 +371,26 @@ static int si2168_init(struct dvb_frontend *fe)
 if (ret)
 goto err;

 +   if (s-fw_loaded) {
 +   /* resume */
 +   memcpy(cmd.args, \xc0\x06\x08\x0f\x00\x20\x21\x01, 8);
 +   cmd.wlen = 8;
 +   cmd.rlen = 1;
 +   ret = si2168_cmd_execute(s, cmd);
 +   if (ret)
 +   goto err;
 +
 +   memcpy(cmd.args, \x85, 1);
 +   cmd.wlen = 1;
 +   cmd.rlen = 1;
 +   ret = si2168_cmd_execute(s, cmd);
 +   if (ret)
 +   goto err;
 +
 +   goto warm;
 +   }
 +
 +   /* power up */
 memcpy(cmd.args, \xc0\x06\x01\x0f\x00\x20\x20\x01, 8);
 cmd.wlen = 8;
 cmd.rlen = 1;
 @@ -466,9 +487,6 @@ static int si2168_init(struct dvb_frontend *fe)
 if (ret)
 goto err;

 -   dev_info(s-client-dev, found a '%s' in warm state\n,
 -   si2168_ops.info.name);
 -
 /* set ts mode */
 memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
 cmd.args[4] |= s-ts_mode;
 @@ -478,6 +496,12 @@ static int si2168_init(struct dvb_frontend *fe)
 if (ret)
 goto err;

 +   s-fw_loaded = true;
 +
 +warm:
 +   dev_info(s-client-dev, found a '%s' in warm state\n,
 +   si2168_ops.info.name);
 +
 s-active = true;

 return 0;
 @@ -645,6 +669,7 @@ static int si2168_probe(struct i2c_client *client,
 *config-i2c_adapter = s-adapter;
 *config-fe = s-fe;
 s-ts_mode = config-ts_mode;
 +   s-fw_loaded = false;

 i2c_set_clientdata(client, s);

 diff --git a/drivers/media/dvb-frontends/si2168_priv.h
 b/drivers/media/dvb-frontends/si2168_priv.h
 index 0f83284..e13983e 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;
 +   bool fw_loaded;
 u8 ts_mode;
   };



 --
 http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] si2168: avoid firmware loading if it has been loaded previously

2014-09-06 Thread Olli Salonen
Moro Antti,

Tried removing the command 85 after resume, but the result is that the
demod doesn't lock after sleep. Curiously this only impacts HD or
DVB-T2 channels. DVB-T SD channels are fine even after resume.

Log of the testing here:
http://paste.ubuntu.com/8271949/

Same thing happens after applying the si2157: sleep hack patch: my
TT CT2-4400 does not lock on the second tune, ie. after sleep.

Log of the testing of that patch is here:
http://paste.ubuntu.com/8271869/

Cheers,
-olli

On 5 September 2014 21:54, Olli Salonen olli.salo...@iki.fi wrote:
 Moro,

 I'll test it once more when testing the si2157 sleep hack you
 posted. Though I remember that the command 85 seemed to be the magic
 trick that finally made it work - I agree it sounds a bit strange
 considering it's run later on anyway. The proprietary driver seems to
 do a command 85 after wake up, but of course that's not a guarantee of
 anything.

 My sniff using the proprietary driver is here:
 http://trsqr.net/olli/ct2-4400/ct2-4400-wakeup-tune-sleep.txt

 Cheers,
 -olli

 On 5 September 2014 11:36, Antti Palosaari cr...@iki.fi wrote:
 Moikka
 Did you really need command 85 here? It will be given later in any case. For
 my Si2168 B40 there was no need for it.

 regards
 Antti

 On 08/25/2014 09:07 PM, Olli Salonen wrote:

 Add a variable to keep track if firmware is loaded or not and skip parts
 of the
 initialization if fw is already loaded. Resume from sleep with a different
 command compared to initial power up and run command 85 after resume
 command.
 This behaviour is observed when using manufacturer provided binary-only
 si2168
 driver for TechnoTrend CT2-4400.

 Signed-off-by: Olli Salonen olli.salo...@iki.fi
 ---
   drivers/media/dvb-frontends/si2168.c  | 31
 ---
   drivers/media/dvb-frontends/si2168_priv.h |  1 +
   2 files changed, 29 insertions(+), 3 deletions(-)

 diff --git a/drivers/media/dvb-frontends/si2168.c
 b/drivers/media/dvb-frontends/si2168.c
 index 55a4212..a0797fd 100644
 --- a/drivers/media/dvb-frontends/si2168.c
 +++ b/drivers/media/dvb-frontends/si2168.c
 @@ -363,6 +363,7 @@ static int si2168_init(struct dvb_frontend *fe)

 dev_dbg(s-client-dev, \n);

 +   /* initialize */
 memcpy(cmd.args,
 \xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00, 13);
 cmd.wlen = 13;
 cmd.rlen = 0;
 @@ -370,6 +371,26 @@ static int si2168_init(struct dvb_frontend *fe)
 if (ret)
 goto err;

 +   if (s-fw_loaded) {
 +   /* resume */
 +   memcpy(cmd.args, \xc0\x06\x08\x0f\x00\x20\x21\x01, 8);
 +   cmd.wlen = 8;
 +   cmd.rlen = 1;
 +   ret = si2168_cmd_execute(s, cmd);
 +   if (ret)
 +   goto err;
 +
 +   memcpy(cmd.args, \x85, 1);
 +   cmd.wlen = 1;
 +   cmd.rlen = 1;
 +   ret = si2168_cmd_execute(s, cmd);
 +   if (ret)
 +   goto err;
 +
 +   goto warm;
 +   }
 +
 +   /* power up */
 memcpy(cmd.args, \xc0\x06\x01\x0f\x00\x20\x20\x01, 8);
 cmd.wlen = 8;
 cmd.rlen = 1;
 @@ -466,9 +487,6 @@ static int si2168_init(struct dvb_frontend *fe)
 if (ret)
 goto err;

 -   dev_info(s-client-dev, found a '%s' in warm state\n,
 -   si2168_ops.info.name);
 -
 /* set ts mode */
 memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
 cmd.args[4] |= s-ts_mode;
 @@ -478,6 +496,12 @@ static int si2168_init(struct dvb_frontend *fe)
 if (ret)
 goto err;

 +   s-fw_loaded = true;
 +
 +warm:
 +   dev_info(s-client-dev, found a '%s' in warm state\n,
 +   si2168_ops.info.name);
 +
 s-active = true;

 return 0;
 @@ -645,6 +669,7 @@ static int si2168_probe(struct i2c_client *client,
 *config-i2c_adapter = s-adapter;
 *config-fe = s-fe;
 s-ts_mode = config-ts_mode;
 +   s-fw_loaded = false;

 i2c_set_clientdata(client, s);

 diff --git a/drivers/media/dvb-frontends/si2168_priv.h
 b/drivers/media/dvb-frontends/si2168_priv.h
 index 0f83284..e13983e 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;
 +   bool fw_loaded;
 u8 ts_mode;
   };



 --
 http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] si2157: Add support for Si2147-A30 tuner

2014-09-11 Thread Olli Salonen
This patch adds support for Si2147-A30 tuner. Fairly trivial, no firmware 
needed for this tuner. However, command 14 00 02 07 01 00 seems to be 
mandatory. On Si2157 and Si2158 the value 0x0100 is the default value, so this 
patch does not impact the existing tuners/devices. On Si2147 the default is 
0x and I can't get a lock with that value.

While here, fix the return length of the previous set command to 4 bytes.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 13 +++--
 drivers/media/tuners/si2157.h  |  2 +-
 drivers/media/tuners/si2157_priv.h |  2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 5901484..cf97142 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157/2158 silicon tuner driver
+ * Silicon Labs Si2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
@@ -113,12 +113,14 @@ static int si2157_init(struct dvb_frontend *fe)
 
#define SI2158_A20 ('A'  24 | 58  16 | '2'  8 | '0'  0)
#define SI2157_A30 ('A'  24 | 57  16 | '3'  8 | '0'  0)
+   #define SI2147_A30 ('A'  24 | 47  16 | '3'  8 | '0'  0)
 
switch (chip_id) {
case SI2158_A20:
fw_file = SI2158_A20_FIRMWARE;
break;
case SI2157_A30:
+   case SI2147_A30:
goto skip_fw_download;
break;
default:
@@ -265,7 +267,14 @@ static int si2157_set_params(struct dvb_frontend *fe)
if (s-inversion)
cmd.args[5] = 0x01;
cmd.wlen = 6;
-   cmd.rlen = 1;
+   cmd.rlen = 4;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   memcpy(cmd.args, \x14\x00\x02\x07\x01\x00, 6);
+   cmd.wlen = 6;
+   cmd.rlen = 4;
ret = si2157_cmd_execute(s, cmd);
if (ret)
goto err;
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index 6da4d5d..d3b19ca 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157/2158 silicon tuner driver
+ * Silicon Labs Si2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index 4080a57..e71ffaf 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157/2158 silicon tuner driver
+ * Silicon Labs Si2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] IT930x USB DVB-T2/C tuner

2014-09-21 Thread Olli Salonen
This patch set adds support for IT930x reference design. It contains IT9303 USB 
bridge, Si2168-B40 demodulator and Si2147-A30 tuner.

The patches should be applied on top of Antti's af9035 branch.
http://git.linuxtv.org/cgit.cgi/anttip/media_tree.git/log/?h=af9035

Cc: cr...@iki.fi

Olli Salonen (3):
  si2157: Add support for Si2147-A30
  af9035: Add possibility to define which I2C adapter to use
  af9035: Add support for IT930x USB bridge

 drivers/media/dvb-core/dvb-usb-ids.h  |   1 +
 drivers/media/tuners/si2157.c |  13 +-
 drivers/media/tuners/si2157.h |   2 +-
 drivers/media/tuners/si2157_priv.h|   2 +-
 drivers/media/usb/dvb-usb-v2/af9035.c | 333 +++---
 drivers/media/usb/dvb-usb-v2/af9035.h |   6 +
 6 files changed, 331 insertions(+), 26 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] si2157: Add support for Si2147-A30

2014-09-21 Thread Olli Salonen
This patch adds support for Si2147-A30 tuner. Fairly trivial, no firmware
needed for this tuner. However, command 14 00 02 07 01 00 seems to be
mandatory. On Si2157 and Si2158 the value 0x0100 is the default value, so this
patch does not impact the existing tuners/devices. On Si2147 the default is
0x and I can't get a lock with that value.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
Cc: cr...@iki.fi
---
 drivers/media/tuners/si2157.c  | 13 +++--
 drivers/media/tuners/si2157.h  |  2 +-
 drivers/media/tuners/si2157_priv.h |  2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index efb5cce..41965c7 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157/2158 silicon tuner driver
+ * Silicon Labs Si2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
@@ -110,12 +110,14 @@ static int si2157_init(struct dvb_frontend *fe)
 
#define SI2158_A20 ('A'  24 | 58  16 | '2'  8 | '0'  0)
#define SI2157_A30 ('A'  24 | 57  16 | '3'  8 | '0'  0)
+   #define SI2147_A30 ('A'  24 | 47  16 | '3'  8 | '0'  0)
 
switch (chip_id) {
case SI2158_A20:
fw_file = SI2158_A20_FIRMWARE;
break;
case SI2157_A30:
+   case SI2147_A30:
goto skip_fw_download;
break;
default:
@@ -258,7 +260,14 @@ static int si2157_set_params(struct dvb_frontend *fe)
if (s-inversion)
cmd.args[5] = 0x01;
cmd.wlen = 6;
-   cmd.rlen = 1;
+   cmd.rlen = 4;
+   ret = si2157_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   memcpy(cmd.args, \x14\x00\x02\x07\x01\x00, 6);
+   cmd.wlen = 6;
+   cmd.rlen = 4;
ret = si2157_cmd_execute(s, cmd);
if (ret)
goto err;
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index 6da4d5d..d3b19ca 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157/2158 silicon tuner driver
+ * Silicon Labs Si2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index 3ddab5e..02350f8 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2157/2158 silicon tuner driver
+ * Silicon Labs Si2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] af9035: Add possibility to define which I2C adapter to use

2014-09-21 Thread Olli Salonen
Some I2C tuner drivers require that the I2C device of the tuner is added to the 
I2C adapter of the demodulator (Si2168+Si2157 for example). Add possibility to 
tell af9035_add_i2c_dev which I2C adapter should be used.

Cc: cr...@iki.fi
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 440ecb4..c50d27d 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -194,12 +194,11 @@ static int af9035_wr_reg_mask(struct dvb_usb_device *d, 
u32 reg, u8 val,
 }
 
 static int af9035_add_i2c_dev(struct dvb_usb_device *d, char *type, u8 addr,
-   void *platform_data)
+   void *platform_data, struct i2c_adapter *adapter)
 {
int ret, num;
struct state *state = d_to_priv(d);
struct i2c_client *client;
-   struct i2c_adapter *adapter = d-i2c_adap;
struct i2c_board_info board_info = {
.addr = addr,
.platform_data = platform_data,
@@ -1091,7 +1090,7 @@ static int af9035_frontend_attach(struct dvb_usb_adapter 
*adap)
state-af9033_config[adap-id].fe = adap-fe[0];
state-af9033_config[adap-id].ops = state-ops;
ret = af9035_add_i2c_dev(d, af9033, state-af9033_i2c_addr[adap-id],
-   state-af9033_config[adap-id]);
+   state-af9033_config[adap-id], d-i2c_adap);
if (ret)
goto err;
 
@@ -1382,7 +1381,7 @@ static int af9035_tuner_attach(struct dvb_usb_adapter 
*adap)
 
ret = af9035_add_i2c_dev(d, it913x,
state-af9033_i2c_addr[adap-id]  1,
-   it913x_config);
+   it913x_config, d-i2c_adap);
if (ret)
goto err;
 
@@ -1407,7 +1406,7 @@ static int af9035_tuner_attach(struct dvb_usb_adapter 
*adap)
 
ret = af9035_add_i2c_dev(d, it913x,
state-af9033_i2c_addr[adap-id]  1,
-   it913x_config);
+   it913x_config, d-i2c_adap);
if (ret)
goto err;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] af9035: Add support for IT930x USB bridge

2014-09-21 Thread Olli Salonen
Add support for IT930x USB bridge and IT9303 reference design.

It is a DVB-T/T2/C tuner with the following components:
- IT9303 USB bridge
- Si2168-B40 demodulator
- Si2147-A30 tuner

The IT9303 requires firmware that can be downloaded here:
http://trsqr.net/olli/linux/firmwares/it930x/

The Si2168-B40 requires firmware, but the one that is used by PCTV 292e can be 
used.
http://palosaari.fi/linux/v4l-dvb/firmware/Si2168/Si2168-B40/

The Si2147-A30 tuner does not require firmware loading.

Cc: cr...@iki.fi
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-core/dvb-usb-ids.h  |   1 +
 drivers/media/usb/dvb-usb-v2/af9035.c | 324 --
 drivers/media/usb/dvb-usb-v2/af9035.h |   6 +
 3 files changed, 314 insertions(+), 17 deletions(-)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index d484a51..e07a84e 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -144,6 +144,7 @@
 #define USB_PID_ITETECH_IT9135 0x9135
 #define USB_PID_ITETECH_IT9135_90050x9005
 #define USB_PID_ITETECH_IT9135_90060x9006
+#define USB_PID_ITETECH_IT9303 0x9306
 #define USB_PID_KWORLD_399U0xe399
 #define USB_PID_KWORLD_399U_2  0xe400
 #define USB_PID_KWORLD_395U0xe396
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index c50d27d..00758c8 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -290,7 +290,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
return -EAGAIN;
 
/*
-* I2C sub header is 5 bytes long. Meaning of those bytes are:
+* AF9035 I2C sub header is 5 bytes long. Meaning of those bytes are:
 * 0: data len
 * 1: I2C addr  1
 * 2: reg addr len
@@ -317,6 +317,12 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
 * bus. I2C subsystem does not allow register multiple devices to same
 * bus, having same slave address. Due to that we reuse demod address,
 * shifted by one bit, on that case.
+*
+* For IT930x we use a different command and the sub header is
+* different as well:
+* 0: data len
+* 1: I2C bus (0x03 seems to be only value used)
+* 2: I2C addr  1
 */
 #define AF9035_IS_I2C_XFER_WRITE_READ(_msg, _num) \
(_num == 2  !(_msg[0].flags  I2C_M_RD)  (_msg[1].flags  I2C_M_RD))
@@ -348,13 +354,24 @@ static int af9035_i2c_master_xfer(struct i2c_adapter 
*adap,
struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len,
buf, msg[1].len, msg[1].buf };
 
+   if (state-chip_type == 0x9306) {
+   req.cmd = CMD_GENERIC_I2C_RD;
+   req.wlen = 3 + msg[0].len;
+   }
req.mbox |= ((msg[0].addr  0x80)3);
+
buf[0] = msg[1].len;
-   buf[1] = msg[0].addr  1;
-   buf[2] = 0x00; /* reg addr len */
-   buf[3] = 0x00; /* reg addr MSB */
-   buf[4] = 0x00; /* reg addr LSB */
-   memcpy(buf[5], msg[0].buf, msg[0].len);
+   if (state-chip_type == 0x9306) {
+   buf[1] = 0x03; /* I2C bus */
+   buf[2] = msg[0].addr  1;
+   memcpy(buf[3], msg[0].buf, msg[0].len);
+   } else {
+   buf[1] = msg[0].addr  1;
+   buf[2] = 0x00; /* reg addr len */
+   buf[3] = 0x00; /* reg addr MSB */
+   buf[4] = 0x00; /* reg addr LSB */
+   memcpy(buf[5], msg[0].buf, msg[0].len);
+   }
ret = af9035_ctrl_msg(d, req);
}
} else if (AF9035_IS_I2C_XFER_WRITE(msg, num)) {
@@ -380,13 +397,24 @@ static int af9035_i2c_master_xfer(struct i2c_adapter 
*adap,
struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len,
buf, 0, NULL };
 
+   if (state-chip_type == 0x9306) {
+   req.cmd = CMD_GENERIC_I2C_WR;
+   req.wlen = 3 + msg[0].len;
+   }
+
req.mbox |= ((msg[0].addr  0x80)3);
buf[0] = msg[0].len;
-   buf[1] = msg[0].addr  1;
-   buf[2] = 0x00; /* reg addr len */
-   buf[3] = 0x00; /* reg addr MSB */
-   buf[4] = 0x00

Re: [PATCH 3/3] af9035: Add support for IT930x USB bridge

2014-09-23 Thread Olli Salonen
Hi Antti,

Thanks for the review. I agree that the I2C xfer does not look too
elegant at the moment. Maybe it could be worth investigating if same
methods could be used for all these devices. Alternatively I could
have created another function for I2C xfer using the I2C_GENERIC_RD
and WR commands, but then again the differences were so small...

Would you suggest to move the non-endpoint related registers somewhere
else from the init function? I just reused that as it was
convenient... Tuner attach?

Cheers,
-olli

On 23 September 2014 15:46, Antti Palosaari cr...@iki.fi wrote:
 Acked-by: Antti Palosaari cr...@iki.fi
 Reviewed-by: Antti Palosaari cr...@iki.fi

 Changes were a bit complicated, but I understood those in general and there
 is nothing wrong for my eyes. Mostly I was surprised of new implementation
 of init() (init is mainly for configuring TS interfaces).

 Also I2C adapter xfer goes pretty complex, but that is because there is
 actually 3 I2C adapters and some of those even offer multiple access methods
 by firmware. Maybe there is also room for later improvement.

 But as I said, patch it is OK.

 regards
 Antti


 On 09/21/2014 01:53 PM, Olli Salonen wrote:

 Add support for IT930x USB bridge and IT9303 reference design.

 It is a DVB-T/T2/C tuner with the following components:
 - IT9303 USB bridge
 - Si2168-B40 demodulator
 - Si2147-A30 tuner

 The IT9303 requires firmware that can be downloaded here:
 http://trsqr.net/olli/linux/firmwares/it930x/

 The Si2168-B40 requires firmware, but the one that is used by PCTV 292e
 can be used.
 http://palosaari.fi/linux/v4l-dvb/firmware/Si2168/Si2168-B40/

 The Si2147-A30 tuner does not require firmware loading.

 Cc: cr...@iki.fi
 Signed-off-by: Olli Salonen olli.salo...@iki.fi
 ---
   drivers/media/dvb-core/dvb-usb-ids.h  |   1 +
   drivers/media/usb/dvb-usb-v2/af9035.c | 324
 --
   drivers/media/usb/dvb-usb-v2/af9035.h |   6 +
   3 files changed, 314 insertions(+), 17 deletions(-)

 diff --git a/drivers/media/dvb-core/dvb-usb-ids.h
 b/drivers/media/dvb-core/dvb-usb-ids.h
 index d484a51..e07a84e 100644
 --- a/drivers/media/dvb-core/dvb-usb-ids.h
 +++ b/drivers/media/dvb-core/dvb-usb-ids.h
 @@ -144,6 +144,7 @@
   #define USB_PID_ITETECH_IT91350x9135
   #define USB_PID_ITETECH_IT9135_9005   0x9005
   #define USB_PID_ITETECH_IT9135_9006   0x9006
 +#define USB_PID_ITETECH_IT9303 0x9306
   #define USB_PID_KWORLD_399U   0xe399
   #define USB_PID_KWORLD_399U_2 0xe400
   #define USB_PID_KWORLD_395U   0xe396
 diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c
 b/drivers/media/usb/dvb-usb-v2/af9035.c
 index c50d27d..00758c8 100644
 --- a/drivers/media/usb/dvb-usb-v2/af9035.c
 +++ b/drivers/media/usb/dvb-usb-v2/af9035.c
 @@ -290,7 +290,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter
 *adap,
 return -EAGAIN;

 /*
 -* I2C sub header is 5 bytes long. Meaning of those bytes are:
 +* AF9035 I2C sub header is 5 bytes long. Meaning of those bytes
 are:
  * 0: data len
  * 1: I2C addr  1
  * 2: reg addr len
 @@ -317,6 +317,12 @@ static int af9035_i2c_master_xfer(struct i2c_adapter
 *adap,
  * bus. I2C subsystem does not allow register multiple devices to
 same
  * bus, having same slave address. Due to that we reuse demod
 address,
  * shifted by one bit, on that case.
 +*
 +* For IT930x we use a different command and the sub header is
 +* different as well:
 +* 0: data len
 +* 1: I2C bus (0x03 seems to be only value used)
 +* 2: I2C addr  1
  */
   #define AF9035_IS_I2C_XFER_WRITE_READ(_msg, _num) \
 (_num == 2  !(_msg[0].flags  I2C_M_RD)  (_msg[1].flags 
 I2C_M_RD))
 @@ -348,13 +354,24 @@ static int af9035_i2c_master_xfer(struct i2c_adapter
 *adap,
 struct usb_req req = { CMD_I2C_RD, 0, 5 +
 msg[0].len,
 buf, msg[1].len, msg[1].buf };

 +   if (state-chip_type == 0x9306) {
 +   req.cmd = CMD_GENERIC_I2C_RD;
 +   req.wlen = 3 + msg[0].len;
 +   }
 req.mbox |= ((msg[0].addr  0x80)3);
 +
 buf[0] = msg[1].len;
 -   buf[1] = msg[0].addr  1;
 -   buf[2] = 0x00; /* reg addr len */
 -   buf[3] = 0x00; /* reg addr MSB */
 -   buf[4] = 0x00; /* reg addr LSB */
 -   memcpy(buf[5], msg[0].buf, msg[0].len);
 +   if (state-chip_type == 0x9306) {
 +   buf[1] = 0x03; /* I2C bus */
 +   buf[2] = msg[0].addr  1;
 +   memcpy

[PATCH] si2168: add FE_CAN_MULTISTREAM into caps

2014-09-23 Thread Olli Salonen
PLP selection was implemented for Si2168 last month (patchwork 25387). However, 
FE_CAN_MULTISTREAM was not added to dvb_frontend_ops of si2168. This patch adds 
FE_CAN_MULTISTREAM, which indicates that multiple PLP are supported.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 55a4212..c7e7446 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -598,7 +598,8 @@ static const struct dvb_frontend_ops si2168_ops = {
FE_CAN_GUARD_INTERVAL_AUTO |
FE_CAN_HIERARCHY_AUTO |
FE_CAN_MUTE_TS |
-   FE_CAN_2G_MODULATION
+   FE_CAN_2G_MODULATION |
+   FE_CAN_MULTISTREAM
},
 
.get_tune_settings = si2168_get_tune_settings,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cx23885: initialize config structs for T9580

2014-09-23 Thread Olli Salonen
The config structs used for DVBSky T9580 were not initialized. This patch fixes 
that.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index 13734b8..4cb9031 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1600,6 +1600,7 @@ static int dvb_register(struct cx23885_tsport *port)
break;
 
/* attach tuner */
+   memset(m88ts2022_config, 0, sizeof(m88ts2022_config));
m88ts2022_config.fe = fe0-dvb.frontend;
m88ts2022_config.clock = 2700;
memset(info, 0, sizeof(struct i2c_board_info));
@@ -1635,6 +1636,7 @@ static int dvb_register(struct cx23885_tsport *port)
/* port c - terrestrial/cable */
case 2:
/* attach frontend */
+   memset(si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = adapter;
si2168_config.fe = fe0-dvb.frontend;
si2168_config.ts_mode = SI2168_TS_SERIAL;
@@ -1654,6 +1656,7 @@ static int dvb_register(struct cx23885_tsport *port)
port-i2c_client_demod = client_demod;
 
/* attach tuner */
+   memset(si2157_config, 0, sizeof(si2157_config));
si2157_config.fe = fe0-dvb.frontend;
memset(info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, si2157, I2C_NAME_SIZE);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] cx23855: add support for DVBSky T980C (no CI support)

2014-09-29 Thread Olli Salonen
This patch adds basic support for DVBSky T980C card. CI interface is not 
supported.

DVBSky T980C is a PCIe card with the following components:
- CX23885 PCIe bridge
- Si2168-A20 demodulator
- Si2158-A20 tuner
- CIMaX SP2 CI chip

The demodulator and tuner need firmware. They're the same as used with TT 
CT2-4650 CI:
https://www.mail-archive.com/linux-media@vger.kernel.org/msg78033.html

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-cards.c | 40 
 drivers/media/pci/cx23885/cx23885-dvb.c   | 61 +++
 drivers/media/pci/cx23885/cx23885.h   |  1 +
 3 files changed, 102 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 88c257d..e8965e6 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -680,6 +680,10 @@ struct cx23885_board cx23885_boards[] = {
.portb  = CX23885_MPEG_DVB,
.portc  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_T980C] = {
+   .name   = DVBSky T980C,
+   .portb  = CX23885_MPEG_DVB,
+   },
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -939,6 +943,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x4254,
.subdevice = 0x9580,
.card  = CX23885_BOARD_DVBSKY_T9580,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x980c,
+   .card  = CX23885_BOARD_DVBSKY_T980C,
},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1541,6 +1549,36 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
mdelay(100);
cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
break;
+   case CX23885_BOARD_DVBSKY_T980C:
+   /*
+* GPIO-0 INTA from CiMax, input
+* GPIO-1 reset CiMax, output, high active
+* GPIO-2 reset demod, output, low active
+* GPIO-3 to GPIO-10 data/addr for CAM
+* GPIO-11 ~CS0 to CiMax1
+* GPIO-12 ~CS1 to CiMax2
+* GPIO-13 ADL0 load LSB addr
+* GPIO-14 ADL1 load MSB addr
+* GPIO-15 ~RDY from CiMax
+* GPIO-17 ~RD to CiMax
+* GPIO-18 ~WR to CiMax
+*/
+
+   cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */
+   cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */
+   mdelay(100); /* reset delay */
+   cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */
+   cx_clear(GP0_IO, 0x00010002);
+   cx_write(MC417_CTL, 0x0037); /* enable GPIO3-18 pins */
+
+   /* GPIO-15 IN as ~ACK, rest as OUT */
+   cx_write(MC417_OEN, 0x1000);
+
+   /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
+   cx_write(MC417_RWD, 0xc300);
+
+   /* enable irq */
+   cx_write(GPIO_ISM, 0x); /* INTERRUPTS active low */
}
 }
 
@@ -1817,6 +1855,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_TEVII_S471:
case CX23885_BOARD_DVBWORLD_2005:
case CX23885_BOARD_PROF_8000:
+   case CX23885_BOARD_DVBSKY_T980C:
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;
@@ -1935,6 +1974,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
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 2f532c9..d327459 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1681,6 +1681,52 @@ static int dvb_register(struct cx23885_tsport *port)
break;
}
break;
+   case CX23885_BOARD_DVBSKY_T980C:
+   i2c_bus = dev-i2c_bus[1];
+
+   /* attach frontend */
+   memset(si2168_config, 0, sizeof(si2168_config));
+   si2168_config.i2c_adapter = adapter;
+   si2168_config.fe = fe0-dvb.frontend;
+   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;
+   info.platform_data = si2168_config

[PATCH 2/5] sp2: fix incorrect struct

2014-09-29 Thread Olli Salonen
Incorrect struct used in the SP2 driver.

Reported-by: Max Nibble nibble@gmail.com
Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/sp2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
index 9b684d5..1f4f250 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -407,7 +407,7 @@ err:
 
 static int sp2_remove(struct i2c_client *client)
 {
-   struct si2157 *s = i2c_get_clientdata(client);
+   struct sp2 *s = i2c_get_clientdata(client);
 
dev_dbg(client-dev, \n);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] sp2: improve debug logging

2014-09-29 Thread Olli Salonen
Improve debugging output.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/sp2.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/sp2.c 
b/drivers/media/dvb-frontends/sp2.c
index 1f4f250..320cbe9 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -92,6 +92,9 @@ static int sp2_write_i2c(struct sp2 *s, u8 reg, u8 *buf, int 
len)
return -EIO;
}
 
+   dev_dbg(s-client-dev, addr=0x%04x, reg = 0x%02x, data = %*ph\n,
+   client-addr, reg, len, buf);
+
return 0;
 }
 
@@ -103,9 +106,6 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, 
int slot, u8 acs,
int mem, ret;
int (*ci_op_cam)(void*, u8, int, u8, int*) = s-ci_control;
 
-   dev_dbg(s-client-dev, slot=%d, acs=0x%02x, addr=0x%04x, data = 
0x%02x,
-   slot, acs, addr, data);
-
if (slot != 0)
return -EINVAL;
 
@@ -140,13 +140,16 @@ static int sp2_ci_op_cam(struct dvb_ca_en50221 *en50221, 
int slot, u8 acs,
if (ret)
return ret;
 
-   if (read) {
-   dev_dbg(s-client-dev, cam read, addr=0x%04x, data = 0x%04x,
-   addr, mem);
+   dev_dbg(s-client-dev, %s: slot=%d, addr=0x%04x, %s, data=%x,
+   (read) ? read : write, slot, addr,
+   (acs == SP2_CI_ATTR_ACS) ? attr : io,
+   (read) ? mem : data);
+
+   if (read)
return mem;
-   } else {
+   else
return 0;
-   }
+
 }
 
 int sp2_ci_read_attribute_mem(struct dvb_ca_en50221 *en50221,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] cx23855: add CI support for DVBSky T980C

2014-09-29 Thread Olli Salonen
Add CI support for DVBSky T980C.

I used the new host device independent CIMaX SP2 I2C driver to implement it.

cx23885_sp2_ci_ctrl function is borrowed entirely from cimax2.c.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 105 +++-
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index cc88997..70dbcd6 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include si2165.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 #include m88ds3103.h
 #include m88ts2022.h
 
@@ -616,6 +617,76 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
return 0;
 }
 
+static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
+   u8 data, int *mem)
+{
+
+   /* MC417 */
+   #define SP2_DATA  0x00ff
+   #define SP2_WR0x8000
+   #define SP2_RD0x4000
+   #define SP2_ACK   0x1000
+   #define SP2_ADHI  0x0800
+   #define SP2_ADLO  0x0400
+   #define SP2_CS1   0x0200
+   #define SP2_CS0   0x0100
+   #define SP2_EN_ALL0x1000
+   #define SP2_CTRL_OFF  (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
+
+   struct cx23885_tsport *port = priv;
+   struct cx23885_dev *dev = port-dev;
+   int ret;
+   int tmp;
+   unsigned long timeout;
+
+   mutex_lock(dev-gpio_lock);
+
+   /* write addr */
+   cx_write(MC417_OEN, SP2_EN_ALL);
+   cx_write(MC417_RWD, SP2_CTRL_OFF |
+   SP2_ADLO | (0xff  addr));
+   cx_clear(MC417_RWD, SP2_ADLO);
+   cx_write(MC417_RWD, SP2_CTRL_OFF |
+   SP2_ADHI | (0xff  (addr  8)));
+   cx_clear(MC417_RWD, SP2_ADHI);
+
+   if (read) { /* data in */
+   cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
+   } else /* data out */
+   cx_write(MC417_RWD, SP2_CTRL_OFF | data);
+
+   /* chip select 0 */
+   cx_clear(MC417_RWD, SP2_CS0);
+
+   /* read/write */
+   cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
+
+   timeout = jiffies + msecs_to_jiffies(1);
+   for (;;) {
+   tmp = cx_read(MC417_RWD);
+   if ((tmp  SP2_ACK) == 0)
+   break;
+   if (time_after(jiffies, timeout))
+   break;
+   udelay(1);
+   }
+
+   cx_set(MC417_RWD, SP2_CTRL_OFF);
+   *mem = tmp  0xff;
+
+   mutex_unlock(dev-gpio_lock);
+
+   if (!read)
+   if (*mem  0) {
+   ret = -EREMOTEIO;
+   goto err;
+   }
+
+   return 0;
+err:
+   return ret;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
struct dtv_frontend_properties *p = fe-dtv_property_cache;
@@ -944,11 +1015,11 @@ static int dvb_register(struct cx23885_tsport *port)
struct vb2_dvb_frontend *fe0, *fe1 = NULL;
struct si2168_config si2168_config;
struct si2157_config si2157_config;
+   struct sp2_config sp2_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;
+   struct i2c_client *client_demod, *client_tuner, *client_ci;
int mfe_shared = 0; /* bus not shared by default */
int ret;
 
@@ -1683,6 +1754,7 @@ static int dvb_register(struct cx23885_tsport *port)
break;
case CX23885_BOARD_DVBSKY_T980C:
i2c_bus = dev-i2c_bus[1];
+   i2c_bus2 = dev-i2c_bus[0];
 
/* attach frontend */
memset(si2168_config, 0, sizeof(si2168_config));
@@ -1820,6 +1892,35 @@ static int dvb_register(struct cx23885_tsport *port)
case CX23885_BOARD_DVBSKY_T980C: {
u8 eeprom[256]; /* 24C02 i2c eeprom */
 
+   /* attach CI */
+   memset(sp2_config, 0, sizeof(sp2_config));
+   sp2_config.dvb_adap = port-frontends.adapter;
+   sp2_config.priv = port;
+   sp2_config.ci_control = cx23885_sp2_ci_ctrl;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, sp2, I2C_NAME_SIZE);
+   info.addr = 0x40;
+   info.platform_data = sp2_config;
+   request_module(info.type);
+   client_ci = i2c_new_device(i2c_bus2-i2c_adap, info);
+   if (client_ci == NULL ||
+   client_ci-dev.driver == NULL) {
+   module_put(client_tuner-dev.driver-owner);
+   i2c_unregister_device

[PATCH 4/5] cx23885: add I2C client for CI into state and handle unregistering

2014-09-29 Thread Olli Salonen
If the CI chip has an I2C driver, we need to store I2C client into state.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 7 +++
 drivers/media/pci/cx23885/cx23885.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index d327459..cc88997 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1923,6 +1923,13 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
 * implement MFE support.
 */
 
+   /* remove I2C client for CI */
+   client = port-i2c_client_ci;
+   if (client) {
+   module_put(client-dev.driver-owner);
+   i2c_unregister_device(client);
+   }
+
/* remove I2C client for tuner */
client = port-i2c_client_tuner;
if (client) {
diff --git a/drivers/media/pci/cx23885/cx23885.h 
b/drivers/media/pci/cx23885/cx23885.h
index 1792d1a..c35ba2d 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -297,6 +297,7 @@ struct cx23885_tsport {
 
struct i2c_client *i2c_client_demod;
struct i2c_client *i2c_client_tuner;
+   struct i2c_client *i2c_client_ci;
 
int (*set_frontend)(struct dvb_frontend *fe);
int (*fe_set_voltage)(struct dvb_frontend *fe,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] cx23855: add CI support for DVBSky T980C

2014-09-29 Thread Olli Salonen
Hi Max,

Thanks for the comments. I looked through the existing CIMaX driver
and came to the conclusion that it can be implemented either with the
IRQs or then just to rely on the polling like the USB devices have to
do. I don't think it's that important, as the user probably will not
add/remove the CAM that often. That being said, of course it would be
nice if we had a config option to choose if IRQ is supported or not.
If you have a patch for that, I'm happy to have it in.

Cheers,
-olli


On 29 September 2014 15:05, Nibble Max nibble@gmail.com wrote:
 Hello,
 In hardware design, the CI host controller is wired with GPIO_0 of CX23885.
 The GPIO_0 can be configed as the interrupt source.
 Interrupt mode in PCIe driver is more faster than poll mode to detect CAM 
 insert/remove operations etc.

Add CI support for DVBSky T980C.

I used the new host device independent CIMaX SP2 I2C driver to implement it.

cx23885_sp2_ci_ctrl function is borrowed entirely from cimax2.c.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 105 
 +++-
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index cc88997..70dbcd6 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include si2165.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 #include m88ds3103.h
 #include m88ts2022.h

@@ -616,6 +617,76 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
   return 0;
 }

+static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
+  u8 data, int *mem)
+{
+
+  /* MC417 */
+  #define SP2_DATA  0x00ff
+  #define SP2_WR0x8000
+  #define SP2_RD0x4000
+  #define SP2_ACK   0x1000
+  #define SP2_ADHI  0x0800
+  #define SP2_ADLO  0x0400
+  #define SP2_CS1   0x0200
+  #define SP2_CS0   0x0100
+  #define SP2_EN_ALL0x1000
+  #define SP2_CTRL_OFF  (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
+
+  struct cx23885_tsport *port = priv;
+  struct cx23885_dev *dev = port-dev;
+  int ret;
+  int tmp;
+  unsigned long timeout;
+
+  mutex_lock(dev-gpio_lock);
+
+  /* write addr */
+  cx_write(MC417_OEN, SP2_EN_ALL);
+  cx_write(MC417_RWD, SP2_CTRL_OFF |
+  SP2_ADLO | (0xff  addr));
+  cx_clear(MC417_RWD, SP2_ADLO);
+  cx_write(MC417_RWD, SP2_CTRL_OFF |
+  SP2_ADHI | (0xff  (addr  8)));
+  cx_clear(MC417_RWD, SP2_ADHI);
+
+  if (read) { /* data in */
+  cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
+  } else /* data out */
+  cx_write(MC417_RWD, SP2_CTRL_OFF | data);
+
+  /* chip select 0 */
+  cx_clear(MC417_RWD, SP2_CS0);
+
+  /* read/write */
+  cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
+
+  timeout = jiffies + msecs_to_jiffies(1);
+  for (;;) {
+  tmp = cx_read(MC417_RWD);
+  if ((tmp  SP2_ACK) == 0)
+  break;
+  if (time_after(jiffies, timeout))
+  break;
+  udelay(1);
+  }
+
+  cx_set(MC417_RWD, SP2_CTRL_OFF);
+  *mem = tmp  0xff;
+
+  mutex_unlock(dev-gpio_lock);
+
+  if (!read)
+  if (*mem  0) {
+  ret = -EREMOTEIO;
+  goto err;
+  }
+
+  return 0;
+err:
+  return ret;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
   struct dtv_frontend_properties *p = fe-dtv_property_cache;
@@ -944,11 +1015,11 @@ static int dvb_register(struct cx23885_tsport *port)
   struct vb2_dvb_frontend *fe0, *fe1 = NULL;
   struct si2168_config si2168_config;
   struct si2157_config si2157_config;
+  struct sp2_config sp2_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;
+  struct i2c_client *client_demod, *client_tuner, *client_ci;
   int mfe_shared = 0; /* bus not shared by default */
   int ret;

@@ -1683,6 +1754,7 @@ static int dvb_register(struct cx23885_tsport *port)
   break;
   case CX23885_BOARD_DVBSKY_T980C:
   i2c_bus = dev-i2c_bus[1];
+  i2c_bus2 = dev-i2c_bus[0];

   /* attach frontend */
   memset(si2168_config, 0, sizeof(si2168_config));
@@ -1820,6 +1892,35 @@ static int dvb_register(struct cx23885_tsport *port)
   case CX23885_BOARD_DVBSKY_T980C: {
   u8 eeprom[256]; /* 24C02 i2c eeprom */

+  /* attach CI */
+  memset

[PATCHv2 5/5] cx23855: add CI support for DVBSky T980C

2014-10-04 Thread Olli Salonen
Add CI support for DVBSky T980C card. The new host device independent CIMaX SP2 
I2C driver was used to implement it.

IRQ handling is not implemented at this point. It could be used to detect the 
CAM insertion/removal instantly.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 106 +++-
 1 file changed, 104 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index cc88997..31d51f8 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include si2165.h
 #include si2168.h
 #include si2157.h
+#include sp2.h
 #include m88ds3103.h
 #include m88ts2022.h
 
@@ -616,6 +617,77 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
return 0;
 }
 
+static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
+   u8 data, int *mem)
+{
+   /* MC417 */
+   #define SP2_DATA  0x00ff
+   #define SP2_WR0x8000
+   #define SP2_RD0x4000
+   #define SP2_ACK   0x1000
+   #define SP2_ADHI  0x0800
+   #define SP2_ADLO  0x0400
+   #define SP2_CS1   0x0200
+   #define SP2_CS0   0x0100
+   #define SP2_EN_ALL0x1000
+   #define SP2_CTRL_OFF  (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
+
+   struct cx23885_tsport *port = priv;
+   struct cx23885_dev *dev = port-dev;
+   int ret;
+   int tmp;
+   unsigned long timeout;
+
+   mutex_lock(dev-gpio_lock);
+
+   /* write addr */
+   cx_write(MC417_OEN, SP2_EN_ALL);
+   cx_write(MC417_RWD, SP2_CTRL_OFF |
+   SP2_ADLO | (0xff  addr));
+   cx_clear(MC417_RWD, SP2_ADLO);
+   cx_write(MC417_RWD, SP2_CTRL_OFF |
+   SP2_ADHI | (0xff  (addr  8)));
+   cx_clear(MC417_RWD, SP2_ADHI);
+
+   if (read)
+   /* data in */
+   cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
+   else
+   /* data out */
+   cx_write(MC417_RWD, SP2_CTRL_OFF | data);
+
+   /* chip select 0 */
+   cx_clear(MC417_RWD, SP2_CS0);
+
+   /* read/write */
+   cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
+
+   /* wait for a maximum of 1 msec */
+   timeout = jiffies + msecs_to_jiffies(1);
+   while (!time_after(jiffies, timeout)) {
+   tmp = cx_read(MC417_RWD);
+   if ((tmp  SP2_ACK) == 0)
+   break;
+   usleep_range(50, 100);
+   }
+
+   cx_set(MC417_RWD, SP2_CTRL_OFF);
+   *mem = tmp  0xff;
+
+   mutex_unlock(dev-gpio_lock);
+
+   if (!read) {
+   if (*mem  0) {
+   ret = -EREMOTEIO;
+   goto err;
+   }
+   }
+
+   return 0;
+err:
+   return ret;
+}
+
 static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
 {
struct dtv_frontend_properties *p = fe-dtv_property_cache;
@@ -944,11 +1016,11 @@ static int dvb_register(struct cx23885_tsport *port)
struct vb2_dvb_frontend *fe0, *fe1 = NULL;
struct si2168_config si2168_config;
struct si2157_config si2157_config;
+   struct sp2_config sp2_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;
+   struct i2c_client *client_demod, *client_tuner, *client_ci;
int mfe_shared = 0; /* bus not shared by default */
int ret;
 
@@ -1683,6 +1755,7 @@ static int dvb_register(struct cx23885_tsport *port)
break;
case CX23885_BOARD_DVBSKY_T980C:
i2c_bus = dev-i2c_bus[1];
+   i2c_bus2 = dev-i2c_bus[0];
 
/* attach frontend */
memset(si2168_config, 0, sizeof(si2168_config));
@@ -1820,6 +1893,35 @@ static int dvb_register(struct cx23885_tsport *port)
case CX23885_BOARD_DVBSKY_T980C: {
u8 eeprom[256]; /* 24C02 i2c eeprom */
 
+   /* attach CI */
+   memset(sp2_config, 0, sizeof(sp2_config));
+   sp2_config.dvb_adap = port-frontends.adapter;
+   sp2_config.priv = port;
+   sp2_config.ci_control = cx23885_sp2_ci_ctrl;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, sp2, I2C_NAME_SIZE);
+   info.addr = 0x40;
+   info.platform_data = sp2_config;
+   request_module(info.type);
+   client_ci = i2c_new_device(i2c_bus2-i2c_adap, info);
+   if (client_ci == NULL ||
+   client_ci-dev.driver == NULL

[PATCH 1/4] dvbsky: don't print MAC address from read_mac_address

2014-10-12 Thread Olli Salonen
The dvb-usb-v2 already prints out the MAC address, no need to print it out also 
here.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 34688c8..502b52c 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -265,8 +265,6 @@ static int dvbsky_read_mac_addr(struct dvb_usb_adapter 
*adap, u8 mac[6])
if (i2c_transfer(d-i2c_adap, msg, 2) == 2)
memcpy(mac, ibuf, 6);
 
-   dev_info(d-udev-dev, dvbsky_usb MAC address=%pM\n, mac);
-
return 0;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] dvbsky: add option to disable IR receiver

2014-10-12 Thread Olli Salonen
Added an option disable_rc that can be used to disable the IR receiver polling 
for this module.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 5c7387a..71a3324 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -25,6 +25,10 @@
 #define DVBSKY_MSG_DELAY   0/*2000*/
 #define DVBSKY_BUF_LEN 64
 
+static int dvb_usb_dvbsky_disable_rc;
+module_param_named(disable_rc, dvb_usb_dvbsky_disable_rc, int, 0644);
+MODULE_PARM_DESC(disable_rc, Disable inbuilt IR receiver.);
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct dvbsky_state {
@@ -218,6 +222,10 @@ static int dvbsky_rc_query(struct dvb_usb_device *d)
 
 static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc 
*rc)
 {
+   if (dvb_usb_dvbsky_disable_rc)
+   return 0;
+
+   rc-map_name   = RC_MAP_DVBSKY;
rc-allowed_protos = RC_BIT_RC5;
rc-query  = dvbsky_rc_query;
rc-interval   = 300;
@@ -450,7 +458,7 @@ static struct dvb_usb_device_properties dvbsky_s960_props = 
{
 
 static const struct usb_device_id dvbsky_id_table[] = {
{ DVB_USB_DEVICE(0x0572, 0x6831,
-   dvbsky_s960_props, DVBSky S960/S860, RC_MAP_DVBSKY) },
+   dvbsky_s960_props, DVBSky S960/S860, NULL) },
{ }
 };
 MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] dvbsky: clean logging

2014-10-12 Thread Olli Salonen
dev_err includes the function name in the log printout, so there is no need to 
include it manually. While here, fix a small grammatical error in the i2c error 
message.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index fabe3f5..5c7387a 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -101,8 +101,7 @@ static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 
gport, u8 value)
obuf[2] = value;
ret = dvbsky_usb_generic_rw(d, obuf, 3, ibuf, 1);
if (ret)
-   dev_err(d-udev-dev, %s: %s() failed=%d\n,
-   KBUILD_MODNAME, __func__, ret);
+   dev_err(d-udev-dev, failed=%d\n, ret);
return ret;
 }
 
@@ -119,7 +118,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
 
if (num  2) {
dev_err(d-udev-dev,
-   dvbsky_usb: too many i2c messages[%d] than 2., num);
+   too many i2c messages[%d], max 2., num);
ret = -EOPNOTSUPP;
goto i2c_error;
}
@@ -127,7 +126,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
if (num == 1) {
if (msg[0].len  60) {
dev_err(d-udev-dev,
-   dvbsky_usb: too many i2c bytes[%d] than 60.,
+   too many i2c bytes[%d], max 60.,
msg[0].len);
ret = -EOPNOTSUPP;
goto i2c_error;
@@ -141,8 +140,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
ret = dvbsky_usb_generic_rw(d, obuf, 4,
ibuf, msg[0].len + 1);
if (ret)
-   dev_err(d-udev-dev, %s: %s() failed=%d\n,
-   KBUILD_MODNAME, __func__, ret);
+   dev_err(d-udev-dev, failed=%d\n, ret);
if (!ret)
memcpy(msg[0].buf, ibuf[1], msg[0].len);
} else {
@@ -154,13 +152,12 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, 
struct i2c_msg msg[],
ret = dvbsky_usb_generic_rw(d, obuf,
msg[0].len + 3, ibuf, 1);
if (ret)
-   dev_err(d-udev-dev, %s: %s() failed=%d\n,
-   KBUILD_MODNAME, __func__, ret);
+   dev_err(d-udev-dev, failed=%d\n, ret);
}
} else {
if ((msg[0].len  60) || (msg[1].len  60)) {
dev_err(d-udev-dev,
-   dvbsky_usb: too many i2c bytes[w-%d][r-%d] than 60.,
+   too many i2c bytes[w-%d][r-%d], max 60.,
msg[0].len, msg[1].len);
ret = -EOPNOTSUPP;
goto i2c_error;
@@ -174,8 +171,7 @@ static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg msg[],
ret = dvbsky_usb_generic_rw(d, obuf,
msg[0].len + 4, ibuf, msg[1].len + 1);
if (ret)
-   dev_err(d-udev-dev, %s: %s() failed=%d\n,
-   KBUILD_MODNAME, __func__, ret);
+   dev_err(d-udev-dev, failed=%d\n, ret);
 
if (!ret)
memcpy(msg[1].buf, ibuf[1], msg[1].len);
@@ -206,8 +202,7 @@ static int dvbsky_rc_query(struct dvb_usb_device *d)
obuf[0] = 0x10;
ret = dvbsky_usb_generic_rw(d, obuf, 1, ibuf, 2);
if (ret)
-   dev_err(d-udev-dev, %s: %s() failed=%d\n,
-   KBUILD_MODNAME, __func__, ret);
+   dev_err(d-udev-dev, failed=%d\n, ret);
if (ret == 0)
code = (ibuf[0]  8) | ibuf[1];
if (code != 0x) {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] dvbsky: added debug logging

2014-10-12 Thread Olli Salonen
Added debug logging using dev_dgb.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 502b52c..fabe3f5 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -68,6 +68,9 @@ static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 
onoff)
u8 obuf_pre[3] = { 0x37, 0, 0 };
u8 obuf_post[3] = { 0x36, 3, 0 };
 
+   dev_dbg(d-udev-dev, state: %s\n, (onoff == 1)
+   ? on : off);
+
mutex_lock(state-stream_mutex);
ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
if (!ret  onoff) {
@@ -91,6 +94,8 @@ static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 
gport, u8 value)
int ret;
u8 obuf[3], ibuf[2];
 
+   dev_dbg(d-udev-dev, gport: %d, value: %d\n, gport, value);
+
obuf[0] = 0x0e;
obuf[1] = gport;
obuf[2] = value;
@@ -234,6 +239,9 @@ static int dvbsky_usb_set_voltage(struct dvb_frontend *fe,
struct dvbsky_state *state = d_to_priv(d);
u8 value;
 
+   dev_dbg(d-udev-dev, voltage: %s\n,
+   (voltage == SEC_VOLTAGE_OFF) ? off : on);
+
if (voltage == SEC_VOLTAGE_OFF)
value = 0;
else
@@ -262,8 +270,10 @@ static int dvbsky_read_mac_addr(struct dvb_usb_adapter 
*adap, u8 mac[6])
}
};
 
-   if (i2c_transfer(d-i2c_adap, msg, 2) == 2)
+   if (i2c_transfer(d-i2c_adap, msg, 2) == 2) {
memcpy(mac, ibuf, 6);
+   dev_dbg(d-udev-dev, MAC: %pM\n, ibuf);
+   }
 
return 0;
 }
@@ -274,6 +284,8 @@ static int dvbsky_usb_read_status(struct dvb_frontend *fe, 
fe_status_t *status)
struct dvbsky_state *state = d_to_priv(d);
int ret;
 
+   dev_dbg(d-udev-dev, \n);
+
ret = state-fe_read_status(fe, status);
 
/* it need resync slave fifo when signal change from unlock to lock.*/
@@ -309,6 +321,9 @@ static int dvbsky_s960_attach(struct dvb_usb_adapter *adap)
struct m88ts2022_config m88ts2022_config = {
.clock = 2700,
};
+
+   dev_dbg(d-udev-dev, \n);
+
memset(info, 0, sizeof(struct i2c_board_info));
 
/* attach demod */
@@ -362,6 +377,8 @@ fail_attach:
 
 static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name)
 {
+   dev_dbg(d-udev-dev, \n);
+
dvbsky_gpio_ctrl(d, 0x04, 1);
msleep(20);
dvbsky_gpio_ctrl(d, 0x83, 0);
@@ -378,6 +395,8 @@ static int dvbsky_init(struct dvb_usb_device *d)
 {
struct dvbsky_state *state = d_to_priv(d);
 
+   dev_dbg(d-udev-dev, \n);
+
/* use default interface */
/*
ret = usb_set_interface(d-udev, 0, 0);
@@ -396,6 +415,8 @@ static void dvbsky_exit(struct dvb_usb_device *d)
struct dvbsky_state *state = d_to_priv(d);
struct i2c_client *client;
 
+   dev_dbg(d-udev-dev, \n);
+
client = state-i2c_client_tuner;
/* remove I2C tuner */
if (client) {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] dvbsky: add option to disable IR receiver

2014-10-12 Thread Olli Salonen

On 12.10.2014 13:12, Antti Palosaari wrote:
  static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct 
dvb_usb_rc *rc)

  {
+if (dvb_usb_dvbsky_disable_rc)
+return 0;
+
+rc-map_name   = RC_MAP_DVBSKY;
  rc-allowed_protos = RC_BIT_RC5;
  rc-query  = dvbsky_rc_query;
  rc-interval   = 300;
@@ -450,7 +458,7 @@ static struct dvb_usb_device_properties 
dvbsky_s960_props = {


  static const struct usb_device_id dvbsky_id_table[] = {
  { DVB_USB_DEVICE(0x0572, 0x6831,
-dvbsky_s960_props, DVBSky S960/S860, RC_MAP_DVBSKY) },
+dvbsky_s960_props, DVBSky S960/S860, NULL) },


Why you removed default keytable too?

I initially thought that it would make sense to set all RC related 
parameters in the get_rc_config function. Of couse I could set 
RC_MAP_DVBSKY as default map and then set it to NULL only if the remote 
controller is disabled. Now that I think of it, it's probably better to 
do it this way. The next DVBSky OEM device might come with another 
remote controller, and we don't want to implement the map selection 
logic into the get_rc_config.


In general I did not see many modules with IR disable function. Is this 
the right way to implement it? I noticed that dvb-usb-v2 had an option 
to disable IR polling, but that will disable it for all dvb-usb-v2 
modules. I have 2 adapters in my HTPC setup and want to disable the IR 
only for the device that uses the dvbsky module.


-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 4/4] dvbsky: add option to disable IR receiver

2014-10-12 Thread Olli Salonen
Add an option to disable remote controller for DVBSky devices by specifying the 
disable_rc option at modprobe.

Signed-off-by: Olli Salonen olli.salo...@iki.fi

---

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 5c7387a..f2d0eb7 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -25,6 +25,10 @@
 #define DVBSKY_MSG_DELAY   0/*2000*/
 #define DVBSKY_BUF_LEN 64
 
+static int dvb_usb_dvbsky_disable_rc;
+module_param_named(disable_rc, dvb_usb_dvbsky_disable_rc, int, 0644);
+MODULE_PARM_DESC(disable_rc, Disable inbuilt IR receiver.);
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 struct dvbsky_state {
@@ -218,6 +222,11 @@ static int dvbsky_rc_query(struct dvb_usb_device *d)
 
 static int dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc 
*rc)
 {
+   if (dvb_usb_dvbsky_disable_rc) {
+   rc-map_name = NULL;
+   return 0;
+   }
+
rc-allowed_protos = RC_BIT_RC5;
rc-query  = dvbsky_rc_query;
rc-interval   = 300;

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] dtv-scan-tables: add mux H to stations transmitting it in Finland

2014-10-19 Thread Olli Salonen
The new mux H is being broadcasted by Digita from 6 stations in Finland.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 dvb-t/fi-Espoo | 15 ++-
 dvb-t/fi-Jyvaskyla | 15 ++-
 dvb-t/fi-Lahti | 15 ++-
 dvb-t/fi-Oulu  | 15 ++-
 dvb-t/fi-Tampere   | 15 ++-
 dvb-t/fi-Turku | 15 ++-
 6 files changed, 60 insertions(+), 30 deletions(-)

diff --git a/dvb-t/fi-Espoo b/dvb-t/fi-Espoo
index 03296ae..ceb906d 100644
--- a/dvb-t/fi-Espoo
+++ b/dvb-t/fi-Espoo
@@ -1,28 +1,33 @@
 # 2014-04-18 Antti Palosaari cr...@iki.fi
 # generated from 
http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet
 
-[Espoo]
+[Espoo-A]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 56200
BANDWIDTH_HZ = 800
 
-[Espoo]
+[Espoo-B]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 65800
BANDWIDTH_HZ = 800
 
-[Espoo]
+[Espoo-C]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 67400
BANDWIDTH_HZ = 800
 
-[Espoo]
+[Espoo-E]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 73000
BANDWIDTH_HZ = 800
 
-[Espoo]
+[Espoo-D]
DELIVERY_SYSTEM = DVBT2
FREQUENCY = 58600
BANDWIDTH_HZ = 800
 
+[Espoo-H]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 51400
+   BANDWIDTH_HZ = 800
+
diff --git a/dvb-t/fi-Jyvaskyla b/dvb-t/fi-Jyvaskyla
index 3e2c51f..02ced9e 100644
--- a/dvb-t/fi-Jyvaskyla
+++ b/dvb-t/fi-Jyvaskyla
@@ -1,28 +1,33 @@
 # 2014-04-18 Antti Palosaari cr...@iki.fi
 # generated from 
http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet
 
-[Jyvaskyla]
+[Jyvaskyla-A]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 54600
BANDWIDTH_HZ = 800
 
-[Jyvaskyla]
+[Jyvaskyla-B]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 78600
BANDWIDTH_HZ = 800
 
-[Jyvaskyla]
+[Jyvaskyla-C]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 74600
BANDWIDTH_HZ = 800
 
-[Jyvaskyla]
+[Jyvaskyla-E]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 63400
BANDWIDTH_HZ = 800
 
-[Jyvaskyla]
+[Jyvaskyla-D]
DELIVERY_SYSTEM = DVBT2
FREQUENCY = 50600
BANDWIDTH_HZ = 800
 
+[Jyvaskyla-H]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 58600
+   BANDWIDTH_HZ = 800
+
diff --git a/dvb-t/fi-Lahti b/dvb-t/fi-Lahti
index d4bf403..f4c89b8 100644
--- a/dvb-t/fi-Lahti
+++ b/dvb-t/fi-Lahti
@@ -1,28 +1,33 @@
 # 2014-04-18 Antti Palosaari cr...@iki.fi
 # generated from 
http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet
 
-[Lahti]
+[Lahti-A]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 57000
BANDWIDTH_HZ = 800
 
-[Lahti]
+[Lahti-B]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 68200
BANDWIDTH_HZ = 800
 
-[Lahti]
+[Lahti-C]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 76200
BANDWIDTH_HZ = 800
 
-[Lahti]
+[Lahti-E]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 71400
BANDWIDTH_HZ = 800
 
-[Lahti]
+[Lahti-D]
DELIVERY_SYSTEM = DVBT2
FREQUENCY = 62600
BANDWIDTH_HZ = 800
 
+[Lahti-H]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 69000
+   BANDWIDTH_HZ = 800
+
diff --git a/dvb-t/fi-Oulu b/dvb-t/fi-Oulu
index 6d10849..0e3906a 100644
--- a/dvb-t/fi-Oulu
+++ b/dvb-t/fi-Oulu
@@ -1,28 +1,33 @@
 # 2014-04-18 Antti Palosaari cr...@iki.fi
 # generated from 
http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet
 
-[Oulu]
+[Oulu-A]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 63400
BANDWIDTH_HZ = 800
 
-[Oulu]
+[Oulu-B]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 71400
BANDWIDTH_HZ = 800
 
-[Oulu]
+[Oulu-C]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 73800
BANDWIDTH_HZ = 800
 
-[Oulu]
+[Oulu-E]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 60200
BANDWIDTH_HZ = 800
 
-[Oulu]
+[Oulu-D]
DELIVERY_SYSTEM = DVBT2
FREQUENCY = 49800
BANDWIDTH_HZ = 800
 
+[Oulu-H]
+   DELIVERY_SYSTEM = DVBT2
+   FREQUENCY = 57000
+   BANDWIDTH_HZ = 800
+
diff --git a/dvb-t/fi-Tampere b/dvb-t/fi-Tampere
index 1440032..27cf3a7 100644
--- a/dvb-t/fi-Tampere
+++ b/dvb-t/fi-Tampere
@@ -1,28 +1,33 @@
 # 2014-04-18 Antti Palosaari cr...@iki.fi
 # generated from 
http://www.digita.fi/kuluttajat/tv/nakyvyysalueet/kanavanumerot_ja_taajuudet
 
-[Tampere]
+[Tampere-A]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 57800
BANDWIDTH_HZ = 800
 
-[Tampere]
+[Tampere-B]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 49000
BANDWIDTH_HZ = 800
 
-[Tampere]
+[Tampere-C]
DELIVERY_SYSTEM = DVBT
FREQUENCY = 77000
BANDWIDTH_HZ = 800
 
-[Tampere]
+[Tampere-E]
DELIVERY_SYSTEM = DVBT
FREQUENCY

[PATCH 2/2] dtv-scan-tables: fix the DNA muxes in Finland to DVB-T2

2014-10-19 Thread Olli Salonen
All of the DNA muxes in Finland are DVB-T2, not DVB-T.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 dvb-t/fi-DNA-Espoo| 6 +++---
 dvb-t/fi-DNA-Eurajoki | 6 +++---
 dvb-t/fi-DNA-Hameenlinna  | 6 +++---
 dvb-t/fi-DNA-Hamina   | 6 +++---
 dvb-t/fi-DNA-Hausjarvi| 6 +++---
 dvb-t/fi-DNA-Helsinki | 6 +++---
 dvb-t/fi-DNA-Jokioinen| 6 +++---
 dvb-t/fi-DNA-Jyvaskyla| 6 +++---
 dvb-t/fi-DNA-Kaarina  | 6 +++---
 dvb-t/fi-DNA-Kajaani  | 6 +++---
 dvb-t/fi-DNA-Kangasala| 6 +++---
 dvb-t/fi-DNA-Karkkila | 6 +++---
 dvb-t/fi-DNA-Kiiminki | 6 +++---
 dvb-t/fi-DNA-Kokkola  | 6 +++---
 dvb-t/fi-DNA-Kontiolahti  | 6 +++---
 dvb-t/fi-DNA-Kouvola  | 6 +++---
 dvb-t/fi-DNA-Kuopio   | 6 +++---
 dvb-t/fi-DNA-Lahti| 6 +++---
 dvb-t/fi-DNA-Lappeenranta | 6 +++---
 dvb-t/fi-DNA-Lohja| 6 +++---
 dvb-t/fi-DNA-Loviisa  | 6 +++---
 dvb-t/fi-DNA-Mikkeli  | 6 +++---
 dvb-t/fi-DNA-Nousiainen   | 6 +++---
 dvb-t/fi-DNA-Nurmijarvi   | 6 +++---
 dvb-t/fi-DNA-Porvoo   | 6 +++---
 dvb-t/fi-DNA-Salo | 6 +++---
 dvb-t/fi-DNA-Savonlinna   | 6 +++---
 dvb-t/fi-DNA-Seinajoki| 6 +++---
 dvb-t/fi-DNA-Tyrnava  | 6 +++---
 dvb-t/fi-DNA-Ulvila   | 6 +++---
 dvb-t/fi-DNA-Vaasa| 6 +++---
 dvb-t/fi-DNA-Valkeakoski  | 6 +++---
 dvb-t/fi-DNA-Vesilahti| 6 +++---
 dvb-t/fi-DNA-Ylivieska| 6 +++---
 34 files changed, 102 insertions(+), 102 deletions(-)

diff --git a/dvb-t/fi-DNA-Espoo b/dvb-t/fi-DNA-Espoo
index f29d2f5..7d74fc1 100644
--- a/dvb-t/fi-DNA-Espoo
+++ b/dvb-t/fi-DNA-Espoo
@@ -1,7 +1,7 @@
 # 2014-03-08 Olli Salonen olli.salo...@iki.fi
 # generated from http://www.dna.fi/tuki-antenniverkon-nakyvyysalueet
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 18450
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -13,7 +13,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 19850
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -25,7 +25,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 17750
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
diff --git a/dvb-t/fi-DNA-Eurajoki b/dvb-t/fi-DNA-Eurajoki
index 8466fd3..31de935 100644
--- a/dvb-t/fi-DNA-Eurajoki
+++ b/dvb-t/fi-DNA-Eurajoki
@@ -1,7 +1,7 @@
 # 2014-03-08 Olli Salonen olli.salo...@iki.fi
 # generated from http://www.dna.fi/tuki-antenniverkon-nakyvyysalueet
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 20550
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -13,7 +13,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 19150
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -25,7 +25,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 18450
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
diff --git a/dvb-t/fi-DNA-Hameenlinna b/dvb-t/fi-DNA-Hameenlinna
index 12f5846..92b4ecf 100644
--- a/dvb-t/fi-DNA-Hameenlinna
+++ b/dvb-t/fi-DNA-Hameenlinna
@@ -1,7 +1,7 @@
 # 2014-03-08 Olli Salonen olli.salo...@iki.fi
 # generated from http://www.dna.fi/tuki-antenniverkon-nakyvyysalueet
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 21950
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -13,7 +13,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 22650
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -25,7 +25,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 21250
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
diff --git a/dvb-t/fi-DNA-Hamina b/dvb-t/fi-DNA-Hamina
index 1098df5..3525cb0 100644
--- a/dvb-t/fi-DNA-Hamina
+++ b/dvb-t/fi-DNA-Hamina
@@ -1,7 +1,7 @@
 # 2014-03-08 Olli Salonen olli.salo...@iki.fi
 # generated from http://www.dna.fi/tuki-antenniverkon-nakyvyysalueet
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 21950
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -13,7 +13,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 19850
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
@@ -25,7 +25,7 @@
INVERSION = AUTO
 
 [CHANNEL]
-   DELIVERY_SYSTEM = DVBT
+   DELIVERY_SYSTEM = DVBT2
FREQUENCY = 22650
BANDWIDTH_HZ = 700
CODE_RATE_HP = AUTO
diff --git a/dvb-t/fi-DNA-Hausjarvi b/dvb-t/fi-DNA-Hausjarvi
index 12f5846..92b4ecf 100644
--- a/dvb-t/fi-DNA-Hausjarvi

[PATCH] cxusb: TS mode setting for TT CT2-4400

2014-10-26 Thread Olli Salonen
There is a new version of the TechnoTrend CT2-4400 USB tuner. The difference is 
the demodulator that is used (Si2168-B40 instead of -A30).

For TT CT2-4400v2 a TS stream related parameter needs to be set, otherwise the 
stream becomes corrupted. The Windows driver for both CT2-4400 and CT2-4400v2 
sets this as well. After this patch the driver works for both versions.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb/cxusb.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index 356abb3..8925b3946 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1438,6 +1438,12 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
si2168_config.i2c_adapter = adapter;
si2168_config.fe = adap-fe_adap[0].fe;
si2168_config.ts_mode = SI2168_TS_PARALLEL;
+
+   /* CT2-4400v2 TS gets corrupted without this */
+   if (d-udev-descriptor.idProduct ==
+   USB_PID_TECHNOTREND_TVSTICK_CT2_4400)
+   si2168_config.ts_mode |= 0x40;
+
memset(info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, si2168, I2C_NAME_SIZE);
info.addr = 0x64;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] dvb-usb-dvbsky: add s960ci dvb-s/s2 usb ci box support

2014-10-26 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Mon, 20 Oct 2014, Nibble Max wrote:


DVBSky s960ci dvb-s/s2 usb ci box:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2usb controller: CY7C86013A
3ci controller: CIMAX SP2 or its clone.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/usb/dvb-usb-v2/Kconfig  |   1 +
drivers/media/usb/dvb-usb-v2/dvbsky.c | 188 ++
2 files changed, 189 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index 5b34323..7423033 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -146,5 +146,6 @@ config DVB_USB_DVBSKY
depends on DVB_USB_V2
select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SP2 if MEDIA_SUBDRV_AUTOSELECT
help
  Say Y here to support the USB receivers from DVBSky.
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 34688c8..e3439f6 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -21,6 +21,7 @@
#include dvb_usb.h
#include m88ds3103.h
#include m88ts2022.h
+#include sp2.h

#define DVBSKY_MSG_DELAY0/*2000*/
#define DVBSKY_BUF_LEN  64
@@ -33,6 +34,7 @@ struct dvbsky_state {
u8 obuf[DVBSKY_BUF_LEN];
u8 last_lock;
struct i2c_client *i2c_client_tuner;
+   struct i2c_client *i2c_client_ci;

/* fe hook functions*/
int (*fe_set_voltage)(struct dvb_frontend *fe,
@@ -362,6 +364,157 @@ fail_attach:
return ret;
}

+static int dvbsky_usb_ci_set_voltage(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage)
+{
+   struct dvb_usb_device *d = fe_to_d(fe);
+   struct dvbsky_state *state = d_to_priv(d);
+   u8 value;
+
+   if (voltage == SEC_VOLTAGE_OFF)
+   value = 0;
+   else
+   value = 1;
+   dvbsky_gpio_ctrl(d, 0x00, value);
+
+   return state-fe_set_voltage(fe, voltage);
+}
+
+static int dvbsky_ci_ctrl(void *priv, u8 read, int addr,
+   u8 data, int *mem)
+{
+   struct dvb_usb_device *d = priv;
+   int ret = 0;
+   u8 command[4], respond[2], command_size, respond_size;
+
+   command[1] = (u8)((addr  8)  0xff); /*high part of address*/
+   command[2] = (u8)(addr  0xff); /*low part of address*/
+   if (read) {
+   command[0] = 0x71;
+   command_size = 3;
+   respond_size = 2;
+   } else {
+   command[0] = 0x70;
+   command[3] = data;
+   command_size = 4;
+   respond_size = 1;
+   }
+   ret = dvbsky_usb_generic_rw(d, command, command_size,
+   respond, respond_size);
+   if (ret)
+   goto err;
+   if (read)
+   *mem = respond[1];
+   return ret;
+err:
+   dev_err(d-udev-dev, ci control failed=%d\n, ret);
+   return ret;
+}
+
+static const struct m88ds3103_config dvbsky_s960c_m88ds3103_config = {
+   .i2c_addr = 0x68,
+   .clock = 2700,
+   .i2c_wr_max = 33,
+   .clock_out = 0,
+   .ts_mode = M88DS3103_TS_CI,
+   .ts_clk = 1,
+   .ts_clk_pol = 1,
+   .agc = 0x99,
+   .lnb_hv_pol = 0,
+   .lnb_en_pol = 1,
+};
+
+static int dvbsky_s960c_attach(struct dvb_usb_adapter *adap)
+{
+   struct dvbsky_state *state = adap_to_priv(adap);
+   struct dvb_usb_device *d = adap_to_d(adap);
+   int ret = 0;
+   /* demod I2C adapter */
+   struct i2c_adapter *i2c_adapter;
+   struct i2c_client *client_tuner, *client_ci;
+   struct i2c_board_info info;
+   struct sp2_config sp2_config;
+   struct m88ts2022_config m88ts2022_config = {
+   .clock = 2700,
+   };
+   memset(info, 0, sizeof(struct i2c_board_info));
+
+   /* attach demod */
+   adap-fe[0] = dvb_attach(m88ds3103_attach,
+   dvbsky_s960c_m88ds3103_config,
+   d-i2c_adap,
+   i2c_adapter);
+   if (!adap-fe[0]) {
+   dev_err(d-udev-dev, dvbsky_s960ci_attach fail.\n);
+   ret = -ENODEV;
+   goto fail_attach;
+   }
+
+   /* attach tuner */
+   m88ts2022_config.fe = adap-fe[0];
+   strlcpy(info.type, m88ts2022, I2C_NAME_SIZE);
+   info.addr = 0x60;
+   info.platform_data = m88ts2022_config;
+   request_module(m88ts2022);
+   client_tuner = i2c_new_device(i2c_adapter, info);
+   if (client_tuner == NULL || client_tuner-dev.driver == NULL) {
+   ret = -ENODEV;
+   goto fail_tuner_device;
+   }
+
+   if (!try_module_get(client_tuner-dev.driver-owner)) {
+   ret = -ENODEV;
+   goto fail_tuner_module;
+   }
+
+   /* attach ci controller

Re: [PATCH] si2157: Add support for delivery system SYS_ATSC

2014-10-30 Thread Olli Salonen

On Thu, 30 Oct 2014, Mauro Carvalho Chehab wrote:


Ah, ok. Are you planning to submit a patch for it, and the patches adding
support for HVR-955Q?


I can submit a patch for that, no problem. However, I'm not working with 
HVR-955Q at the moment. I don't have access to ATSC/ClearQAM signal.


If someone is working with that, I can put you in contact with someone 
who is interested in that device and is able to test.


Cheers,
-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] si2157: add support for SYS_DVBC_ANNEX_B

2014-10-30 Thread Olli Salonen
Set the property for delivery system also in case of SYS_DVBC_ANNEX_B. This 
behaviour is observed in the sniffs taken with Hauppauge HVR-955Q Windows 
driver.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index cf97142..b086b87 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -250,6 +250,9 @@ static int si2157_set_params(struct dvb_frontend *fe)
case SYS_ATSC:
delivery_system = 0x00;
break;
+   case SYS_DVBC_ANNEX_B:
+   delivery_system = 0x10;
+   break;
case SYS_DVBT:
case SYS_DVBT2: /* it seems DVB-T and DVB-T2 both are 0x20 here */
delivery_system = 0x20;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] cx23885: add DVBSky S950C dvb-s/s2 ci PCIe card support(no RC)

2014-10-30 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Thu, 23 Oct 2014, Nibble Max wrote:


DVBSky s950ci dvb-s/s2 ci PCIe card:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2ci controller: CIMAX SP2 or its clone.
3PCIe bridge: CX23885

The patchs are based on the following patchs.
Olli Salonen submit:
https://patchwork.linuxtv.org/patch/26180/
https://patchwork.linuxtv.org/patch/26183/
https://patchwork.linuxtv.org/patch/26324/
Nibble Max submit:
https://patchwork.linuxtv.org/patch/26207/

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/pci/cx23885/cx23885-cards.c | 11 +
drivers/media/pci/cx23885/cx23885-dvb.c   | 79 ++-
drivers/media/pci/cx23885/cx23885.h   |  1 +
3 files changed, 80 insertions(+), 11 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index c4a69e4..ac34c27 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -684,6 +684,10 @@ struct cx23885_board cx23885_boards[] = {
.name   = DVBSky T980C,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_S950C] = {
+   .name   = DVBSky S950C,
+   .portb  = CX23885_MPEG_DVB,
+   },
};
const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);

@@ -947,6 +951,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x4254,
.subdevice = 0x980c,
.card  = CX23885_BOARD_DVBSKY_T980C,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x950c,
+   .card  = CX23885_BOARD_DVBSKY_S950C,
},
};
const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1550,6 +1558,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
break;
case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
/*
 * GPIO-0 INTA from CiMax, input
 * GPIO-1 reset CiMax, output, high active
@@ -1859,6 +1868,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBWORLD_2005:
case CX23885_BOARD_PROF_8000:
case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
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;
@@ -1978,6 +1988,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
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 efa05ee..f86b7c79 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -635,7 +635,7 @@ static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int 
addr,
struct cx23885_tsport *port = priv;
struct cx23885_dev *dev = port-dev;
int ret;
-   int tmp;
+   int tmp = 0;
unsigned long timeout;

mutex_lock(dev-gpio_lock);
@@ -865,6 +865,19 @@ static const struct m88ds3103_config 
dvbsky_t9580_m88ds3103_config = {
.agc = 0x99,
};

+static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
+   .i2c_addr = 0x68,
+   .clock = 2700,
+   .i2c_wr_max = 33,
+   .clock_out = 0,
+   .ts_mode = M88DS3103_TS_CI,
+   .ts_clk = 1,
+   .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;
@@ -1020,7 +1033,7 @@ static int dvb_register(struct cx23885_tsport *port)
struct m88ts2022_config m88ts2022_config;
struct i2c_board_info info;
struct i2c_adapter *adapter;
-   struct i2c_client *client_demod, *client_tuner, *client_ci;
+   struct i2c_client *client_demod = NULL, *client_tuner = NULL, 
*client_ci = NULL;
int mfe_shared = 0; /* bus not shared by default */
int ret;

@@ -1796,6 +1809,41 @@ static int dvb_register(struct cx23885_tsport *port)
}
port-i2c_client_tuner = client_tuner;
break;
+   case CX23885_BOARD_DVBSKY_S950C:
+   i2c_bus = dev-i2c_bus[1];
+   i2c_bus2 = dev-i2c_bus[0];
+
+   /* attach frontend */
+   fe0-dvb.frontend = dvb_attach(m88ds3103_attach

Re: [PATCH 2/2] cx23885: add DVBSky S950C and T980C RC support

2014-10-30 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Thu, 23 Oct 2014, Nibble Max wrote:


DVBSky s950ci dvb-s/s2 ci PCIe card:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2ci controller: CIMAX SP2 or its clone.
3PCIe bridge: CX23885

The patchs are based on the following patchs.
Olli Salonen submit:
https://patchwork.linuxtv.org/patch/26180/
https://patchwork.linuxtv.org/patch/26183/
https://patchwork.linuxtv.org/patch/26324/
Nibble Max submit:
https://patchwork.linuxtv.org/patch/26207/

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/pci/cx23885/cx23885-cards.c | 6 ++
drivers/media/pci/cx23885/cx23885-input.c | 6 ++
2 files changed, 12 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index ac34c27..d9ba48c 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -1669,6 +1669,8 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1716,6 +1718,8 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1764,6 +1768,8 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
diff --git a/drivers/media/pci/cx23885/cx23885-input.c 
b/drivers/media/pci/cx23885/cx23885-input.c
index f81c2f9..0bf6839 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -88,6 +88,8 @@ void cx23885_input_rx_work_handler(struct cx23885_dev *dev, 
u32 events)
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
/*
 * The only boards we handle right now.  However other boards
 * using the CX2388x integrated IR controller should be similar
@@ -141,6 +143,8 @@ static int cx23885_input_ir_start(struct cx23885_dev *dev)
case CX23885_BOARD_HAUPPAUGE_HVR1250:
case CX23885_BOARD_MYGICA_X8507:
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
/*
 * The IR controller on this board only returns pulse widths.
 * Any other mode setting will fail to set up the device.
@@ -308,6 +312,8 @@ int cx23885_input_init(struct cx23885_dev *dev)
rc_map = RC_MAP_TBS_NEC;
break;
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_DVBSKY_S950C:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL;

--
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cx23885: add support for TechnoTrend CT2-4500 CI

2014-10-30 Thread Olli Salonen
TechnoTrend CT2-4500 CI is a PCIe device with DVB-T2/C tuner. It is similar to 
DVBSky T980C, just with different PCI ID and remote controller.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/pci/cx23885/cx23885-cards.c | 14 ++
 drivers/media/pci/cx23885/cx23885-dvb.c   |  8 +---
 drivers/media/pci/cx23885/cx23885-input.c |  8 
 drivers/media/pci/cx23885/cx23885.h   |  1 +
 4 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index d9ba48c..9c7e8ac 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -688,6 +688,10 @@ struct cx23885_board cx23885_boards[] = {
.name   = DVBSky S950C,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_TT_CT2_4500_CI] = {
+   .name   = Technotrend TT-budget CT2-4500 CI,
+   .portb  = CX23885_MPEG_DVB,
+   },
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -955,6 +959,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x4254,
.subdevice = 0x950c,
.card  = CX23885_BOARD_DVBSKY_S950C,
+   }, {
+   .subvendor = 0x13c2,
+   .subdevice = 0x3013,
+   .card  = CX23885_BOARD_TT_CT2_4500_CI,
},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1559,6 +1567,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
break;
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
/*
 * GPIO-0 INTA from CiMax, input
 * GPIO-1 reset CiMax, output, high active
@@ -1671,6 +1680,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1720,6 +1730,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1770,6 +1781,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
@@ -1875,6 +1887,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_PROF_8000:
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
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;
@@ -1995,6 +2008,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
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 f82eb18..5e6caed 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1766,6 +1766,7 @@ static int dvb_register(struct cx23885_tsport *port)
}
break;
case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_TT_CT2_4500_CI:
i2c_bus = dev-i2c_bus[1];
i2c_bus2 = dev-i2c_bus[0];
 
@@ -1938,7 +1939,8 @@ static int dvb_register(struct cx23885_tsport *port)
break;
}
case CX23885_BOARD_DVBSKY_S950C:
-   case CX23885_BOARD_DVBSKY_T980C: {
+   case CX23885_BOARD_DVBSKY_T980C:
+   case CX23885_BOARD_TT_CT2_4500_CI: {
u8 eeprom[256]; /* 24C02 i2c eeprom */
 
/* attach CI */
@@ -1985,8 +1987,8 @@ static int dvb_register(struct cx23885_tsport *port)
dev-i2c_bus[0].i2c_client.addr = 0xa0  1;
tveeprom_read(dev-i2c_bus[0].i2c_client, eeprom,
sizeof

Re: [PATCH] cx23885: add support for TechnoTrend CT2-4500 CI

2014-10-30 Thread Olli Salonen

On Thu, 30 Oct 2014, Olli Salonen wrote:

TechnoTrend CT2-4500 CI is a PCIe device with DVB-T2/C tuner. It is 
similar to DVBSky T980C, just with different PCI ID and remote 
controller.


Additional note, this should be applied on top of Max Nibble's commits:
http://www.mail-archive.com/linux-media@vger.kernel.org/msg80865.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg80866.html

In patchwork they're 26538 and 26539.

Cheers,
-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] cx23885: add DVBSky S950 support

2014-11-06 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Wed, 5 Nov 2014, Nibble Max wrote:


DVBSky S950 dvb-s/s2 PCIe card:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2PCIe bridge: cx23885
3rc: cx23885 integrated.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/pci/cx23885/cx23885-cards.c | 20 
drivers/media/pci/cx23885/cx23885-dvb.c   |  9 ++---
drivers/media/pci/cx23885/cx23885-input.c |  3 +++
drivers/media/pci/cx23885/cx23885.h   |  1 +
4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 9c7e8ac..4b9cb07 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -692,6 +692,10 @@ struct cx23885_board cx23885_boards[] = {
.name   = Technotrend TT-budget CT2-4500 CI,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_S950] = {
+   .name   = DVBSky S950,
+   .portb  = CX23885_MPEG_DVB,
+   },
};
const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);

@@ -963,6 +967,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x13c2,
.subdevice = 0x3013,
.card  = CX23885_BOARD_TT_CT2_4500_CI,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0950,
+   .card  = CX23885_BOARD_DVBSKY_S950,
},
};
const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1597,6 +1605,13 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)

/* enable irq */
cx_write(GPIO_ISM, 0x); /* INTERRUPTS active low */
+   break;
+   case CX23885_BOARD_DVBSKY_S950:
+   cx23885_gpio_enable(dev, GPIO_2, 1);
+   cx23885_gpio_clear(dev, GPIO_2);
+   msleep(100);
+   cx23885_gpio_set(dev, GPIO_2);
+   break;
}
}

@@ -1681,6 +1696,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1731,6 +1747,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1782,6 +1799,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
@@ -1888,6 +1906,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
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;
@@ -2009,6 +2028,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
+   case CX23885_BOARD_DVBSKY_S950:
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 9da5cf3..3410ab8 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1672,6 +1672,7 @@ static int dvb_register(struct cx23885_tsport *port)
}
break;
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_S950:
i2c_bus = dev-i2c_bus[0];
i2c_bus2 = dev-i2c_bus[1];
switch (port-nr) {
@@ -1922,7 +1923,8 @@ static int dvb_register(struct cx23885_tsport *port)
memcpy(port-frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
break;
}
-   case CX23885_BOARD_DVBSKY_T9580: {
+   case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_S950: {
u8 eeprom[256]; /* 24C02 i2c eeprom */

if (port-nr  2

Re: [PATCH 2/3] cx23885: add DVBSky S952 support

2014-11-06 Thread Olli Salonen

Looks good to me. Only missing T982 support now?

Reviewed-by: Olli Salonen olli.salo...@iki.fi

-olli

On Wed, 5 Nov 2014, Nibble Max wrote:


DVBSky S952 dvb-s/s2 dual PCIe card:
1dvb frontend: M88TS2022(tuner),M88DS3103(demod)
2PCIe bridge: CX23885(port b: parallel mode, port c: serial mode)
3rc: cx23885 integrated.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/pci/cx23885/cx23885-cards.c | 22 +++
drivers/media/pci/cx23885/cx23885-dvb.c   | 99 ++-
drivers/media/pci/cx23885/cx23885-input.c |  3 +
drivers/media/pci/cx23885/cx23885.h   |  1 +
4 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 4b9cb07..4bad27d 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -696,6 +696,11 @@ struct cx23885_board cx23885_boards[] = {
.name   = DVBSky S950,
.portb  = CX23885_MPEG_DVB,
},
+   [CX23885_BOARD_DVBSKY_S952] = {
+   .name   = DVBSky S952,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   },
};
const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);

@@ -971,6 +976,10 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x4254,
.subdevice = 0x0950,
.card  = CX23885_BOARD_DVBSKY_S950,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0952,
+   .card  = CX23885_BOARD_DVBSKY_S952,
},
};
const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1566,6 +1575,7 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
mdelay(60);
break;
case CX23885_BOARD_DVBSKY_T9580:
+   case CX23885_BOARD_DVBSKY_S952:
/* enable GPIO3-18 pins */
cx_write(MC417_CTL, 0x0037);
cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
@@ -1697,6 +1707,7 @@ int cx23885_ir_init(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
if (!enable_885_ir)
break;
dev-sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1748,6 +1759,7 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
/* sd_ir is a duplicate pointer to the AV Core, just clear it */
dev-sd_ir = NULL;
@@ -1800,6 +1812,7 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
if (dev-sd_ir)
cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
break;
@@ -1962,6 +1975,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_S952:
+   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  = 0xe; /* 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:
@@ -2029,6 +2050,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_TT_CT2_4500_CI:
case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_DVBSKY_S952:
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 3410ab8..2457b64 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -617,6 +617,32 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend 
*fe,
return 0;
}

+static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage)
+{
+   struct cx23885_tsport *port = fe-dvb-priv;
+   struct

Re: [PATCH 1/1] dvb-usb-dvbsky: add T680CI dvb-t2/t/c usb ci box support

2014-11-13 Thread Olli Salonen

Hi Max,

My understanding is that T680CI is the same device as TechnoTrend CT2-4650 
CI that is already supported by the cxusb driver. I think we should not 
duplicate this over two drivers. In my opinion, two options exist:


- you add T680CI in the dvbsky driver and move CT2-4650 also to dvbsky
- you add T680CI into cxusb driver

What do you think?

Cheers,
-olli

On Thu, 13 Nov 2014, Nibble Max wrote:


DVBSky T680CI dvb-t2/t/c usb ci box:
1dvb frontend: SI2158A20(tuner), SI2168A30(demod)
2usb controller: CY7C86013A
3ci controller: CIMAX SP2 or its clone.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/usb/dvb-usb-v2/Kconfig  |   2 +
drivers/media/usb/dvb-usb-v2/dvbsky.c | 122 ++
2 files changed, 124 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index 7423033..0982e73 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -145,7 +145,9 @@ config DVB_USB_DVBSKY
tristate DVBSky USB support
depends on DVB_USB_V2
select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
select DVB_SP2 if MEDIA_SUBDRV_AUTOSELECT
help
  Say Y here to support the USB receivers from DVBSky.
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index 8be8447..b6326c6 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -22,6 +22,8 @@
#include m88ds3103.h
#include m88ts2022.h
#include sp2.h
+#include si2168.h
+#include si2157.h

#define DVBSKY_MSG_DELAY0/*2000*/
#define DVBSKY_BUF_LEN  64
@@ -37,6 +39,7 @@ struct dvbsky_state {
u8 ibuf[DVBSKY_BUF_LEN];
u8 obuf[DVBSKY_BUF_LEN];
u8 last_lock;
+   struct i2c_client *i2c_client_demod;
struct i2c_client *i2c_client_tuner;
struct i2c_client *i2c_client_ci;

@@ -517,6 +520,90 @@ fail_attach:
return ret;
}

+static int dvbsky_t680c_attach(struct dvb_usb_adapter *adap)
+{
+   struct dvbsky_state *state = adap_to_priv(adap);
+   struct dvb_usb_device *d = adap_to_d(adap);
+   int ret = 0;
+   struct i2c_adapter *i2c_adapter;
+   struct i2c_client *client_demod, *client_tuner, *client_ci;
+   struct i2c_board_info info;
+   struct si2168_config si2168_config;
+   struct si2157_config si2157_config;
+   struct sp2_config sp2_config;
+
+   /* attach demod */
+   memset(si2168_config, 0, sizeof(si2168_config));
+   si2168_config.i2c_adapter = i2c_adapter;
+   si2168_config.fe = adap-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;
+   info.platform_data = si2168_config;
+
+   request_module(info.type);
+   client_demod = i2c_new_device(d-i2c_adap, info);
+   if (client_demod == NULL ||
+   client_demod-dev.driver == NULL)
+   goto fail_demod_device;
+   if (!try_module_get(client_demod-dev.driver-owner))
+   goto fail_demod_module;
+
+   /* attach tuner */
+   memset(si2157_config, 0, sizeof(si2157_config));
+   si2157_config.fe = adap-fe[0];
+   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(i2c_adapter, info);
+   if (client_tuner == NULL ||
+   client_tuner-dev.driver == NULL)
+   goto fail_tuner_device;
+   if (!try_module_get(client_tuner-dev.driver-owner))
+   goto fail_tuner_module;
+
+   /* attach ci controller */
+   memset(sp2_config, 0, sizeof(sp2_config));
+   sp2_config.dvb_adap = adap-dvb_adap;
+   sp2_config.priv = d;
+   sp2_config.ci_control = dvbsky_ci_ctrl;
+   memset(info, 0, sizeof(struct i2c_board_info));
+   strlcpy(info.type, sp2, I2C_NAME_SIZE);
+   info.addr = 0x40;
+   info.platform_data = sp2_config;
+
+   request_module(info.type);
+   client_ci = i2c_new_device(d-i2c_adap, info);
+
+   if (client_ci == NULL || client_ci-dev.driver == NULL)
+   goto fail_ci_device;
+
+   if (!try_module_get(client_ci-dev.driver-owner))
+   goto fail_ci_module;
+
+   state-i2c_client_demod = client_demod;
+   state-i2c_client_tuner = client_tuner;
+   state-i2c_client_ci = client_ci;
+   return ret;
+fail_ci_module:
+   i2c_unregister_device(client_ci);
+fail_ci_device:
+   module_put(client_tuner-dev.driver-owner);
+fail_tuner_module:
+   

Re: [PATCH 1/3] tuners: si2157: Si2148 support.

2014-11-15 Thread Olli Salonen
What about defining the firmware for Si2148-A20, but since the file is
the same as Si2158-A20 just point to the same file?

#define SI2148_A20_FIRMWARE dvb-tuner-si2158-a20-01.fw

Then if Si2158-A20 would in the future get a new firmware that would
not work with Si2148, this would not break Si2148.

Another point that came to my mind is that we start to have quite a
list of chips there in the printouts (Si2147/Si2148/Si2157/Si2158) and
more is coming - I'm working with an Si2146 device currently. Should
we just say Si214x/Si215x there or something?

Cheers,
-olli

On 15 November 2014 03:22, CrazyCat crazyca...@narod.ru wrote:
 2148 is 2158 without analog support. Same firmware.

 15.11.2014, 03:02, Antti Palosaari cr...@iki.fi:
 I wonder if we should define own firmware for Si2148-A20 just for sure.
 Olli?
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] tuners: si2157: Si2148 support.

2014-11-15 Thread Olli Salonen

On Sat, 15 Nov 2014, Antti Palosaari wrote:


Assuming you rename possible new firmware:
dvb-tuner-si2158-a20-01.fw
dvb-tuner-si2158-a20-02.fw ?

Basically, you would not like to rename firmware when it is updated if it is 
compatible with the driver. Lets say firmware gets bug fixes, just introduce 
new firmware with same name. If driver changes are needed, then you have to 
rename it. These firmware changes are always problematic as you have to think 
possible regression - it is regression from the user point of view if kernel 
driver updates but it does not work as firmware incompatibility.


Indeed, I assumed whenever there's a firmware update, we create a new 
filename for that. If that's not the case, then better to keep Si2148 and 
Si2158 totally separate. At this point the files would be identical of 
course.



How about Si2146 firmware you are working?


No firmware loaded for that.

Cheers,
-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SAA7164 firmware for Asus MyCinema

2014-11-20 Thread Olli Salonen

On Wed, 19 Nov 2014, Éder Zsolt wrote:


Hi,

I found at the site: http://www.linuxtv.org/wiki/index.php/ATSC_PCIe_Cards 
that if I have a TV-tuner card which is currently unsupported, you may help 
me how I can make workable this device.


I have an Asus MyCinema EHD3-100/NAQ/FM/AV/MCE RC dual TV-Tuner card with 
SAA7164 chipset.


Did we talk about this in IRC a couple of days ago?

If not, you will need to find out which demodulator and tuner are used on 
that card. You can find those by looking at the physical card. Read the 
text on the bigger ICs and try to put them in the google to find out the 
components used. The tuner might be under metal shielding, in which case 
it might be a bit more tricky to find out.


Looking at the files in the Windows driver package might give you some 
hints as well.


Cheers,
-olli

Re: [PATCH 1/1] dvb-usb-dvbsky: add T680CI dvb-t2/t/c usb ci box support

2014-11-20 Thread Olli Salonen

Hi Max,

I think this is ok. In the nearby future, would be good to move TT 
CT2-4650 CI support to the dvbsky driver as that one is a rebadged T680CI 
anyway. If you will add T330 support as well, we could move CT2-4400 too..


Reviewed-by: Olli Salonen olli.salo...@iki.fi

Cheers,
-olli

On Thu, 13 Nov 2014, Nibble Max wrote:


DVBSky T680CI dvb-t2/t/c usb ci box:
1dvb frontend: SI2158A20(tuner), SI2168A30(demod)
2usb controller: CY7C86013A
3ci controller: CIMAX SP2 or its clone.

Signed-off-by: Nibble Max nibble@gmail.com

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] si2168: TS clock inversion control.

2014-11-20 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Fri, 14 Nov 2014, CrazyCat wrote:


TS clock polarity control implemented.

Signed-off-by: Evgeny Plehov evgenyple...@ukr.net
---
drivers/media/dvb-frontends/si2168.c  | 7 +--
drivers/media/dvb-frontends/si2168.h  | 4 
drivers/media/dvb-frontends/si2168_priv.h | 1 +
3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 7bac748..16a347a 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -308,14 +308,16 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
if (ret)
goto err;

-   memcpy(cmd.args, \x14\x00\x09\x10\xe3\x18, 6);
+   memcpy(cmd.args, \x14\x00\x09\x10\xe3\x08, 6);
+   cmd.args[5] |= s-ts_clock_inv ? 0x00 : 0x10;
cmd.wlen = 6;
cmd.rlen = 4;
ret = si2168_cmd_execute(s, cmd);
if (ret)
goto err;

-   memcpy(cmd.args, \x14\x00\x08\x10\xd7\x15, 6);
+   memcpy(cmd.args, \x14\x00\x08\x10\xd7\x05, 6);
+   cmd.args[5] |= s-ts_clock_inv ? 0x00 : 0x10;
cmd.wlen = 6;
cmd.rlen = 4;
ret = si2168_cmd_execute(s, cmd);
@@ -669,6 +671,7 @@ static int si2168_probe(struct i2c_client *client,
*config-i2c_adapter = s-adapter;
*config-fe = s-fe;
s-ts_mode = config-ts_mode;
+   s-ts_clock_inv = config-ts_clock_inv;
s-fw_loaded = false;

i2c_set_clientdata(client, s);
diff --git a/drivers/media/dvb-frontends/si2168.h 
b/drivers/media/dvb-frontends/si2168.h
index e086d67..87bc121 100644
--- a/drivers/media/dvb-frontends/si2168.h
+++ b/drivers/media/dvb-frontends/si2168.h
@@ -37,6 +37,10 @@ struct si2168_config {

/* TS mode */
u8 ts_mode;
+
+   /* TS clock inverted */
+   bool ts_clock_inv;
+
};

#define SI2168_TS_PARALLEL  0x06
diff --git a/drivers/media/dvb-frontends/si2168_priv.h 
b/drivers/media/dvb-frontends/si2168_priv.h
index 132df67..66ed675 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;
u8 ts_mode;
+   bool ts_clock_inv;
bool active;
bool fw_loaded;
};
--
1.9.1


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] cxusb: Geniatech T230 support.

2014-11-20 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Fri, 14 Nov 2014, CrazyCat wrote:


Geniatech Mygica T230 DVB-T/T2/C USB stick support.

Signed-off-by: Evgeny Plehov evgenyple...@ukr.net
---
drivers/media/dvb-core/dvb-usb-ids.h |   1 +
drivers/media/usb/dvb-usb/cxusb.c| 127 +++
2 files changed, 128 insertions(+)

diff --git a/drivers/media/dvb-core/dvb-usb-ids.h 
b/drivers/media/dvb-core/dvb-usb-ids.h
index e07a84e..80ab8d0 100644
--- a/drivers/media/dvb-core/dvb-usb-ids.h
+++ b/drivers/media/dvb-core/dvb-usb-ids.h
@@ -356,6 +356,7 @@
#define USB_PID_MSI_DIGI_VOX_MINI_III   0x8807
#define USB_PID_SONY_PLAYTV 0x0003
#define USB_PID_MYGICA_D689 0xd811
+#define USB_PID_MYGICA_T2300xc688
#define USB_PID_ELGATO_EYETV_DIVERSITY  0x0011
#define USB_PID_ELGATO_EYETV_DTT0x0021
#define USB_PID_ELGATO_EYETV_DTT_2  0x003f
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index b46f84d..7346698 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1408,6 +1408,76 @@ static int cxusb_mygica_d689_frontend_attach(struct 
dvb_usb_adapter *adap)
return 0;
}

+static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap)
+{
+   struct dvb_usb_device *d = adap-dev;
+   struct cxusb_state *st = d-priv;
+   struct i2c_adapter *adapter;
+   struct i2c_client *client_demod;
+   struct i2c_client *client_tuner;
+   struct i2c_board_info info;
+   struct si2168_config si2168_config;
+   struct si2157_config si2157_config;
+
+   /* Select required USB configuration */
+   if (usb_set_interface(d-udev, 0, 0)  0)
+   err(set interface failed);
+
+   /* Unblock all USB pipes */
+   usb_clear_halt(d-udev,
+   usb_sndbulkpipe(d-udev, d-props.generic_bulk_ctrl_endpoint));
+   usb_clear_halt(d-udev,
+   usb_rcvbulkpipe(d-udev, d-props.generic_bulk_ctrl_endpoint));
+   usb_clear_halt(d-udev,
+   usb_rcvbulkpipe(d-udev, 
d-props.adapter[0].fe[0].stream.endpoint));
+
+   /* attach frontend */
+   si2168_config.i2c_adapter = adapter;
+   si2168_config.fe = adap-fe_adap[0].fe;
+   si2168_config.ts_mode = SI2168_TS_PARALLEL;
+   si2168_config.ts_clock_inv = 1;
+   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(d-i2c_adap, info);
+   if (client_demod == NULL || client_demod-dev.driver == NULL)
+   return -ENODEV;
+
+   if (!try_module_get(client_demod-dev.driver-owner)) {
+   i2c_unregister_device(client_demod);
+   return -ENODEV;
+   }
+
+   st-i2c_client_demod = client_demod;
+
+   /* attach tuner */
+   memset(si2157_config, 0, sizeof(si2157_config));
+   si2157_config.fe = adap-fe_adap[0].fe;
+   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);
+   return -ENODEV;
+   }
+   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);
+   return -ENODEV;
+   }
+
+   st-i2c_client_tuner = client_tuner;
+
+   return 0;
+}
+
static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
{
struct dvb_usb_device *d = adap-dev;
@@ -1609,6 +1679,7 @@ static struct dvb_usb_device_properties 
cxusb_bluebird_nano2_needsfirmware_prope
static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
+static struct dvb_usb_device_properties cxusb_mygica_t230_properties;
static struct dvb_usb_device_properties cxusb_tt_ct2_4400_properties;

static int cxusb_probe(struct usb_interface *intf,
@@ -1640,6 +1711,8 @@ static int cxusb_probe(struct usb_interface *intf,
 THIS_MODULE, NULL, adapter_nr) ||
0 == dvb_usb_device_init(intf, cxusb_mygica_d689_properties,
 THIS_MODULE, NULL, adapter_nr) ||
+   0 == dvb_usb_device_init(intf, cxusb_mygica_t230_properties

Re: [PATCH 1/3] tuners: si2157: Si2148 support.

2014-11-20 Thread Olli Salonen

On Mon, 17 Nov 2014, Michael Holzer wrote:


I'd see merit to show the supported chips explicitly as otherwise users
may be confused if a new unsupported chip  (lets assume Si2159)
appears and the message is generic as proposed Si215x.
To get clarity for this case source code reading would be required.


Well, the user of a Si2159 would never see the printout as the driver 
would not be loaded for a Si2159 user. I'd say just print something like 
Si215x/Si216x Silicon Tuner in the printouts and list all the chips in 
the source code. But that's not something that needs to be fixed now 
anyway, we can do that later.


Crazycat, do you think you could change the firmware loading for Si2148 
as discussed here though and send a new patch?


Cheers,
-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] em28xx: initialize si2168_config struct

2014-11-20 Thread Olli Salonen
When new parameters are added for si2168 driver, the parameters have to be 
explicitly defined for each device if the
si2168_config struct is not initialized to all zeros.

Signed-off-by: Olli Salonen olli.salo...@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 65a456d..5a94f17 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1553,6 +1553,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
struct si2157_config si2157_config;
 
/* attach demod */
+   memset(si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = adapter;
si2168_config.fe = dvb-fe[0];
si2168_config.ts_mode = SI2168_TS_PARALLEL;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] af9035: initialize si2168_config struct

2014-11-20 Thread Olli Salonen
When new parameters are added for si2168 driver, the parameters have to be 
explicitly defined for each device if the
si2168_config struct is not initialized to all zeros.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c 
b/drivers/media/usb/dvb-usb-v2/af9035.c
index 1896ab2..80a29f5 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -1171,6 +1171,7 @@ static int it930x_frontend_attach(struct dvb_usb_adapter 
*adap)
 
dev_dbg(d-udev-dev, adap-id=%d\n, adap-id);
 
+   memset(si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = adapter;
si2168_config.fe = adap-fe[0];
si2168_config.ts_mode = SI2168_TS_SERIAL;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] cxusb: initialize si2168_config struct

2014-11-20 Thread Olli Salonen
When new parameters are added for si2168 driver, the parameters have to be 
explicitly defined for each device if the 
si2168_config struct is not initialized to all zeros.

Signed-off-by: Olli Salonen olli.salo...@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 356abb3..ef73c93 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -1435,6 +1435,7 @@ static int cxusb_tt_ct2_4400_attach(struct 
dvb_usb_adapter *adap)
msleep(100);
 
/* attach frontend */
+   memset(si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = adapter;
si2168_config.fe = adap-fe_adap[0].fe;
si2168_config.ts_mode = SI2168_TS_PARALLEL;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SAA7164 firmware for Asus MyCinema

2014-11-22 Thread Olli Salonen
Hi Zsolt,

In order to support a card in Linux in general, there needs to be a
driver for the PCIe bridge, the demodulator and the tuner. Then these
building blocks must be put together in a way that makes sense.

You've already identified the PCIe bridge (NXP SAA7164), the
demodulator (TDA 10046) and the tuner (Taifun 6034T aka Infineon
TUA6034). Now here comes the bad news - even if the PCIe bridge and
the demod are supported by existing drivers, the TUA6034 is not
supported by currently. You would need to write or get someone to
write a driver for the TUA6034. In order for this to be possible you'd
need to get the specifications from the manufacturer (often not
possible, but worth trying) or reverse-engineer the Windows driver
(often quite tricky, especially since taking a trace from a PCIe
device can be a lot of work).

Might I suggest that you add also a wiki page in the LinuxTV wiki if
you're anyway looking at this? Basically you can document the same
things you've very well documented on your website there, but please
use the template that the other devices on the site are more or less
using. http://www.linuxtv.org/wiki/index.php/ASUS is a good starting
point. Even if the conclusion is that the card will not work your
research might save someone else time in the future.

Cheers,
-olli


On 22 November 2014 at 23:41, Éder Zsolt zsolt.e...@edernet.hu wrote:
 Hi Olli,

 Sorry, unfortunately was not me on IRC.

 So as you wrote, I followed your instructions, and I collect as information
 as I can from the board.
 I made a small site quickly with some photos, you found it here:
 http://myoop.hu/tuner.html

 While I took the photos I found that my card is Asus MyCinema
 EHD2-100/PT/FM/AV/RC.

 Can you help me how should I continue my work with this tuner?

 Thank you very much in advance.

 Best regards,
 Zsolt

 2014.11.20. 20:51 keltezéssel, Olli Salonen írta:

 On Wed, 19 Nov 2014, Éder Zsolt wrote:

 Hi,

 I found at the site:
 http://www.linuxtv.org/wiki/index.php/ATSC_PCIe_Cards that if I have a
 TV-tuner card which is currently unsupported, you may help me how I can make
 workable this device.

 I have an Asus MyCinema EHD3-100/NAQ/FM/AV/MCE RC dual TV-Tuner card with
 SAA7164 chipset.


 Did we talk about this in IRC a couple of days ago?

 If not, you will need to find out which demodulator and tuner are used on
 that card. You can find those by looking at the physical card. Read the text
 on the bigger ICs and try to put them in the google to find out the
 components used. The tuner might be under metal shielding, in which case it
 might be a bit more tricky to find out.

 Looking at the files in the Windows driver package might give you some
 hints as well.

 Cheers,
 -olli


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] em28xx: Add support for Terratec Cinergy T2 Stick HD

2014-11-23 Thread Olli Salonen
Terratec Cinergy T2 Stick HD [eb1a:8179] is a USB DVB-T/T2/C tuner that 
contains following components:

* Empia EM28178 USB bridge
* Silicon Labs Si2168-A30 demodulator
* Silicon Labs Si2146-A10 tuner

I don't have the remote, so the RC_MAP is a best guess based on the pictures of 
the remote controllers and other supported Terratec devices with a similar 
remote.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/em28xx/em28xx-cards.c | 27 +++
 drivers/media/usb/em28xx/em28xx-dvb.c   | 58 +
 drivers/media/usb/em28xx/em28xx.h   |  1 +
 3 files changed, 86 insertions(+)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 71fa51e..382018d 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -479,6 +479,20 @@ static struct em28xx_reg_seq pctv_292e[] = {
{-1, -1,   -1, -1},
 };
 
+static struct em28xx_reg_seq terratec_t2_stick_hd[] = {
+   {EM2874_R80_GPIO_P0_CTRL,   0xff,   0xff,   0},
+   {0x0d,  0xff,   0xff,   600},
+   {EM2874_R80_GPIO_P0_CTRL,   0xfc,   0xff,   10},
+   {EM2874_R80_GPIO_P0_CTRL,   0xbc,   0xff,   100},
+   {EM2874_R80_GPIO_P0_CTRL,   0xfc,   0xff,   100},
+   {EM2874_R80_GPIO_P0_CTRL,   0x00,   0xff,   300},
+   {EM2874_R80_GPIO_P0_CTRL,   0xf8,   0xff,   100},
+   {EM2874_R80_GPIO_P0_CTRL,   0xfc,   0xff,   300},
+   {0x0d,  0x42,   0xff,   1000},
+   {EM2874_R5F_TS_ENABLE,  0x85,   0xff,   0},
+   {-1, -1,   -1, -1},
+};
+
 /*
  *  Button definitions
  */
@@ -2243,6 +2257,17 @@ struct em28xx_board em28xx_boards[] = {
.has_dvb   = 1,
.ir_codes  = RC_MAP_PINNACLE_PCTV_HD,
},
+   /* eb1a:8179 Terratec Cinergy T2 Stick HD.
+* Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2146 */
+   [EM28178_BOARD_TERRATEC_T2_STICK_HD] = {
+   .name  = Terratec Cinergy T2 Stick HD,
+   .def_i2c_bus   = 1,
+   .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | 
EM28XX_I2C_FREQ_400_KHZ,
+   .tuner_type= TUNER_ABSENT,
+   .tuner_gpio= terratec_t2_stick_hd,
+   .has_dvb   = 1,
+   .ir_codes  = RC_MAP_TERRATEC_SLIM_2,
+   },
 };
 EXPORT_SYMBOL_GPL(em28xx_boards);
 
@@ -2424,6 +2449,8 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM28178_BOARD_PCTV_461E },
{ USB_DEVICE(0x2013, 0x025f),
.driver_info = EM28178_BOARD_PCTV_292E },
+   { USB_DEVICE(0xeb1a, 0x8179),
+   .driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD },
{ },
 };
 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index 65a456d..536815f 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1603,6 +1603,64 @@ static int em28xx_dvb_init(struct em28xx *dev)
dvb-fe[0]-ops.set_lna = em28xx_pctv_292e_set_lna;
}
break;
+   case EM28178_BOARD_TERRATEC_T2_STICK_HD:
+   {
+   struct i2c_adapter *adapter;
+   struct i2c_client *client;
+   struct i2c_board_info info;
+   struct si2168_config si2168_config;
+   struct si2157_config si2157_config;
+
+   /* 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;
+   info.platform_data = si2168_config;
+   request_module(info.type);
+   client = 
i2c_new_device(dev-i2c_adap[dev-def_i2c_bus], info);
+   if (client == NULL || client-dev.driver == NULL) {
+   result = -ENODEV;
+   goto out_free;
+   }
+
+   if (!try_module_get(client-dev.driver-owner)) {
+   i2c_unregister_device(client);
+   result = -ENODEV;
+   goto out_free;
+   }
+
+   dvb-i2c_client_demod = client;
+
+   /* attach tuner */
+   memset(si2157_config, 0, sizeof(si2157_config));
+   si2157_config.fe = dvb-fe[0

[PATCH 1/2] si2157: Add support for Si2146-A10

2014-11-23 Thread Olli Salonen
The Silicon Labs Si2146 tuner seems to work with the same driver as the Si2157, 
but there a few exceptions. The powerup command seems to be quite a bit 
different. In addition there's a property 0207 that requires a different value. 
Thus another entry is created in the si2157_id table to support also si2146 in 
this driver.

The datasheet is available on manufacturer's website:
http://www.silabs.com/support%20documents/technicaldocs/Si2146-short.pdf

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 23 +++
 drivers/media/tuners/si2157_priv.h |  5 +
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index b086b87..e867b28 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -93,8 +93,13 @@ static int si2157_init(struct dvb_frontend *fe)
goto warm;
 
/* power up */
-   memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
-   cmd.wlen = 15;
+   if (s-chiptype == SI2157_CHIPTYPE_SI2146) {
+   memcpy(cmd.args, \xc0\x05\x01\x00\x00\x0b\x00\x00\x01, 9);
+   cmd.wlen = 9;
+   } else {
+   memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
+   cmd.wlen = 15;
+   }
cmd.rlen = 1;
ret = si2157_cmd_execute(s, cmd);
if (ret)
@@ -114,6 +119,7 @@ static int si2157_init(struct dvb_frontend *fe)
#define SI2158_A20 ('A'  24 | 58  16 | '2'  8 | '0'  0)
#define SI2157_A30 ('A'  24 | 57  16 | '3'  8 | '0'  0)
#define SI2147_A30 ('A'  24 | 47  16 | '3'  8 | '0'  0)
+   #define SI2146_A10 ('A'  24 | 46  16 | '1'  8 | '0'  0)
 
switch (chip_id) {
case SI2158_A20:
@@ -121,6 +127,7 @@ static int si2157_init(struct dvb_frontend *fe)
break;
case SI2157_A30:
case SI2147_A30:
+   case SI2146_A10:
goto skip_fw_download;
break;
default:
@@ -275,7 +282,10 @@ static int si2157_set_params(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   memcpy(cmd.args, \x14\x00\x02\x07\x01\x00, 6);
+   if (s-chiptype == SI2157_CHIPTYPE_SI2146)
+   memcpy(cmd.args, \x14\x00\x02\x07\x00\x01, 6);
+   else
+   memcpy(cmd.args, \x14\x00\x02\x07\x01\x00, 6);
cmd.wlen = 6;
cmd.rlen = 4;
ret = si2157_cmd_execute(s, cmd);
@@ -339,6 +349,7 @@ static int si2157_probe(struct i2c_client *client,
s-fe = cfg-fe;
s-inversion = cfg-inversion;
s-fw_loaded = false;
+   s-chiptype = (u8)id-driver_data;
mutex_init(s-i2c_mutex);
 
/* check if the tuner is there */
@@ -355,7 +366,10 @@ static int si2157_probe(struct i2c_client *client,
i2c_set_clientdata(client, s);
 
dev_info(s-client-dev,
-   Silicon Labs Si2157/Si2158 successfully attached\n);
+   Silicon Labs %s successfully attached\n,
+   s-chiptype == SI2157_CHIPTYPE_SI2146 ?
+   Si2146 : Si2147/2157/2158);
+
return 0;
 err:
dev_dbg(client-dev, failed=%d\n, ret);
@@ -380,6 +394,7 @@ static int si2157_remove(struct i2c_client *client)
 
 static const struct i2c_device_id si2157_id[] = {
{si2157, 0},
+   {si2146, 1},
{}
 };
 MODULE_DEVICE_TABLE(i2c, si2157_id);
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index e71ffaf..66ecf30 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -28,8 +28,13 @@ struct si2157 {
bool active;
bool fw_loaded;
bool inversion;
+   u8 chiptype;
 };
 
+#define SI2157_CHIPTYPE_SI2157 0
+#define SI2157_CHIPTYPE_SI2146 1
+
+
 /* firmare command struct */
 #define SI2157_ARGLEN  30
 struct si2157_cmd {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 1/4] si2157: Add support for Si2146-A10

2014-11-23 Thread Olli Salonen
The Silicon Labs Si2146 tuner seems to work with the same driver as the Si2157, 
but there a few exceptions. The powerup command seems to be quite a bit 
different. In addition there's a property 0207 that requires a different value. 
Thus another entry is created in the si2157_id table to support also si2146 in 
this driver.

The datasheet is available on manufacturer's website:
http://www.silabs.com/support%20documents/technicaldocs/Si2146-short.pdf

Patch v2 adds also updates the descriptions to contain the newly supported chip.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 29 ++---
 drivers/media/tuners/si2157.h  |  2 +-
 drivers/media/tuners/si2157_priv.h |  8 ++--
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index b086b87..a8f2edb9 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2147/2157/2158 silicon tuner driver
+ * Silicon Labs Si2146/2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
@@ -93,8 +93,13 @@ static int si2157_init(struct dvb_frontend *fe)
goto warm;
 
/* power up */
-   memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
-   cmd.wlen = 15;
+   if (s-chiptype == SI2157_CHIPTYPE_SI2146) {
+   memcpy(cmd.args, \xc0\x05\x01\x00\x00\x0b\x00\x00\x01, 9);
+   cmd.wlen = 9;
+   } else {
+   memcpy(cmd.args, 
\xc0\x00\x0c\x00\x00\x01\x01\x01\x01\x01\x01\x02\x00\x00\x01, 15);
+   cmd.wlen = 15;
+   }
cmd.rlen = 1;
ret = si2157_cmd_execute(s, cmd);
if (ret)
@@ -114,6 +119,7 @@ static int si2157_init(struct dvb_frontend *fe)
#define SI2158_A20 ('A'  24 | 58  16 | '2'  8 | '0'  0)
#define SI2157_A30 ('A'  24 | 57  16 | '3'  8 | '0'  0)
#define SI2147_A30 ('A'  24 | 47  16 | '3'  8 | '0'  0)
+   #define SI2146_A10 ('A'  24 | 46  16 | '1'  8 | '0'  0)
 
switch (chip_id) {
case SI2158_A20:
@@ -121,6 +127,7 @@ static int si2157_init(struct dvb_frontend *fe)
break;
case SI2157_A30:
case SI2147_A30:
+   case SI2146_A10:
goto skip_fw_download;
break;
default:
@@ -275,7 +282,10 @@ static int si2157_set_params(struct dvb_frontend *fe)
if (ret)
goto err;
 
-   memcpy(cmd.args, \x14\x00\x02\x07\x01\x00, 6);
+   if (s-chiptype == SI2157_CHIPTYPE_SI2146)
+   memcpy(cmd.args, \x14\x00\x02\x07\x00\x01, 6);
+   else
+   memcpy(cmd.args, \x14\x00\x02\x07\x01\x00, 6);
cmd.wlen = 6;
cmd.rlen = 4;
ret = si2157_cmd_execute(s, cmd);
@@ -308,7 +318,7 @@ static int si2157_get_if_frequency(struct dvb_frontend *fe, 
u32 *frequency)
 
 static const struct dvb_tuner_ops si2157_ops = {
.info = {
-   .name   = Silicon Labs Si2157/Si2158,
+   .name   = Silicon Labs Si2146/2147/2157/2158,
.frequency_min  = 11000,
.frequency_max  = 86200,
},
@@ -339,6 +349,7 @@ static int si2157_probe(struct i2c_client *client,
s-fe = cfg-fe;
s-inversion = cfg-inversion;
s-fw_loaded = false;
+   s-chiptype = (u8)id-driver_data;
mutex_init(s-i2c_mutex);
 
/* check if the tuner is there */
@@ -355,7 +366,10 @@ static int si2157_probe(struct i2c_client *client,
i2c_set_clientdata(client, s);
 
dev_info(s-client-dev,
-   Silicon Labs Si2157/Si2158 successfully attached\n);
+   Silicon Labs %s successfully attached\n,
+   s-chiptype == SI2157_CHIPTYPE_SI2146 ?
+   Si2146 : Si2147/2157/2158);
+
return 0;
 err:
dev_dbg(client-dev, failed=%d\n, ret);
@@ -380,6 +394,7 @@ static int si2157_remove(struct i2c_client *client)
 
 static const struct i2c_device_id si2157_id[] = {
{si2157, 0},
+   {si2146, 1},
{}
 };
 MODULE_DEVICE_TABLE(i2c, si2157_id);
@@ -396,7 +411,7 @@ static struct i2c_driver si2157_driver = {
 
 module_i2c_driver(si2157_driver);
 
-MODULE_DESCRIPTION(Silicon Labs Si2157/Si2158 silicon tuner driver);
+MODULE_DESCRIPTION(Silicon Labs Si2146/2147/2157/2158 silicon tuner driver);
 MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
 MODULE_LICENSE(GPL);
 MODULE_FIRMWARE(SI2158_A20_FIRMWARE);
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index d3b19ca..8467d08 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2147/2157/2158 silicon tuner driver
+ * Silicon Labs Si2146/2147/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
diff --git

[PATCHv2 2/4] em28xx: Add support for Terratec Cinergy T2 Stick HD

2014-11-23 Thread Olli Salonen
Terratec Cinergy T2 Stick HD [eb1a:8179] is a USB DVB-T/T2/C tuner that 
contains following components:

* Empia EM28178 USB bridge
* Silicon Labs Si2168-A30 demodulator
* Silicon Labs Si2146-A10 tuner

I don't have the remote, so the RC_MAP is a best guess based on the pictures of 
the remote controllers and other supported Terratec devices with a similar 
remote.

Patch v2 initializes struct si2168_config with zeroes.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/usb/em28xx/em28xx-cards.c | 27 +++
 drivers/media/usb/em28xx/em28xx-dvb.c   | 59 +
 drivers/media/usb/em28xx/em28xx.h   |  1 +
 3 files changed, 87 insertions(+)

diff --git a/drivers/media/usb/em28xx/em28xx-cards.c 
b/drivers/media/usb/em28xx/em28xx-cards.c
index 71fa51e..382018d 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -479,6 +479,20 @@ static struct em28xx_reg_seq pctv_292e[] = {
{-1, -1,   -1, -1},
 };
 
+static struct em28xx_reg_seq terratec_t2_stick_hd[] = {
+   {EM2874_R80_GPIO_P0_CTRL,   0xff,   0xff,   0},
+   {0x0d,  0xff,   0xff,   600},
+   {EM2874_R80_GPIO_P0_CTRL,   0xfc,   0xff,   10},
+   {EM2874_R80_GPIO_P0_CTRL,   0xbc,   0xff,   100},
+   {EM2874_R80_GPIO_P0_CTRL,   0xfc,   0xff,   100},
+   {EM2874_R80_GPIO_P0_CTRL,   0x00,   0xff,   300},
+   {EM2874_R80_GPIO_P0_CTRL,   0xf8,   0xff,   100},
+   {EM2874_R80_GPIO_P0_CTRL,   0xfc,   0xff,   300},
+   {0x0d,  0x42,   0xff,   1000},
+   {EM2874_R5F_TS_ENABLE,  0x85,   0xff,   0},
+   {-1, -1,   -1, -1},
+};
+
 /*
  *  Button definitions
  */
@@ -2243,6 +2257,17 @@ struct em28xx_board em28xx_boards[] = {
.has_dvb   = 1,
.ir_codes  = RC_MAP_PINNACLE_PCTV_HD,
},
+   /* eb1a:8179 Terratec Cinergy T2 Stick HD.
+* Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2146 */
+   [EM28178_BOARD_TERRATEC_T2_STICK_HD] = {
+   .name  = Terratec Cinergy T2 Stick HD,
+   .def_i2c_bus   = 1,
+   .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | 
EM28XX_I2C_FREQ_400_KHZ,
+   .tuner_type= TUNER_ABSENT,
+   .tuner_gpio= terratec_t2_stick_hd,
+   .has_dvb   = 1,
+   .ir_codes  = RC_MAP_TERRATEC_SLIM_2,
+   },
 };
 EXPORT_SYMBOL_GPL(em28xx_boards);
 
@@ -2424,6 +2449,8 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM28178_BOARD_PCTV_461E },
{ USB_DEVICE(0x2013, 0x025f),
.driver_info = EM28178_BOARD_PCTV_292E },
+   { USB_DEVICE(0xeb1a, 0x8179),
+   .driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD },
{ },
 };
 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index 65a456d..bd12f4c 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -1603,6 +1603,65 @@ static int em28xx_dvb_init(struct em28xx *dev)
dvb-fe[0]-ops.set_lna = em28xx_pctv_292e_set_lna;
}
break;
+   case EM28178_BOARD_TERRATEC_T2_STICK_HD:
+   {
+   struct i2c_adapter *adapter;
+   struct i2c_client *client;
+   struct i2c_board_info info;
+   struct si2168_config si2168_config;
+   struct si2157_config si2157_config;
+
+   /* attach demod */
+   memset(si2168_config, 0, sizeof(si2168_config));
+   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;
+   info.platform_data = si2168_config;
+   request_module(info.type);
+   client = 
i2c_new_device(dev-i2c_adap[dev-def_i2c_bus], info);
+   if (client == NULL || client-dev.driver == NULL) {
+   result = -ENODEV;
+   goto out_free;
+   }
+
+   if (!try_module_get(client-dev.driver-owner)) {
+   i2c_unregister_device(client);
+   result = -ENODEV;
+   goto out_free;
+   }
+
+   dvb-i2c_client_demod = client;
+
+   /* attach tuner

[PATCH 3/4] si2157: make checkpatch.pl happy (remove break after goto)

2014-11-23 Thread Olli Salonen
Break after goto is unnecessary.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index a8f2edb9..3bdf00a 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -129,7 +129,6 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2147_A30:
case SI2146_A10:
goto skip_fw_download;
-   break;
default:
dev_err(s-client-dev,
unknown chip version Si21%d-%c%c%c\n,
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] si2157: Add support for Si2148-A20

2014-11-23 Thread Olli Salonen
The Silicon Labs Si2148 tuner works as the Si2158, but does not contain analog 
tuner. A firmware is required for the tuner. Currently the Si2158-A20 firmware 
will work for Si2148-A20 as well, but as there are no guarantees that that will 
be the case in future, a unique file name is used for the firmware.

The datasheet is available on manufacturer's website:
http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2148-short.pdf

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/tuners/si2157.c  | 13 +
 drivers/media/tuners/si2157.h  |  2 +-
 drivers/media/tuners/si2157_priv.h |  3 ++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
index 3bdf00a..e6d7f35 100644
--- a/drivers/media/tuners/si2157.c
+++ b/drivers/media/tuners/si2157.c
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2146/2147/2157/2158 silicon tuner driver
+ * Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
@@ -118,6 +118,7 @@ static int si2157_init(struct dvb_frontend *fe)
 
#define SI2158_A20 ('A'  24 | 58  16 | '2'  8 | '0'  0)
#define SI2157_A30 ('A'  24 | 57  16 | '3'  8 | '0'  0)
+   #define SI2148_A20 ('A'  24 | 48  16 | '2'  8 | '0'  0)
#define SI2147_A30 ('A'  24 | 47  16 | '3'  8 | '0'  0)
#define SI2146_A10 ('A'  24 | 46  16 | '1'  8 | '0'  0)
 
@@ -125,6 +126,9 @@ static int si2157_init(struct dvb_frontend *fe)
case SI2158_A20:
fw_file = SI2158_A20_FIRMWARE;
break;
+   case SI2148_A20:
+   fw_file = SI2148_A20_FIRMWARE;
+   break;
case SI2157_A30:
case SI2147_A30:
case SI2146_A10:
@@ -317,7 +321,7 @@ static int si2157_get_if_frequency(struct dvb_frontend *fe, 
u32 *frequency)
 
 static const struct dvb_tuner_ops si2157_ops = {
.info = {
-   .name   = Silicon Labs Si2146/2147/2157/2158,
+   .name   = Silicon Labs Si2146/2147/2148/2157/2158,
.frequency_min  = 11000,
.frequency_max  = 86200,
},
@@ -367,7 +371,7 @@ static int si2157_probe(struct i2c_client *client,
dev_info(s-client-dev,
Silicon Labs %s successfully attached\n,
s-chiptype == SI2157_CHIPTYPE_SI2146 ?
-   Si2146 : Si2147/2157/2158);
+   Si2146 : Si2147/2148/2157/2158);
 
return 0;
 err:
@@ -410,7 +414,8 @@ static struct i2c_driver si2157_driver = {
 
 module_i2c_driver(si2157_driver);
 
-MODULE_DESCRIPTION(Silicon Labs Si2146/2147/2157/2158 silicon tuner driver);
+MODULE_DESCRIPTION(Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner 
driver);
 MODULE_AUTHOR(Antti Palosaari cr...@iki.fi);
 MODULE_LICENSE(GPL);
+MODULE_FIRMWARE(SI2148_A20_FIRMWARE);
 MODULE_FIRMWARE(SI2158_A20_FIRMWARE);
diff --git a/drivers/media/tuners/si2157.h b/drivers/media/tuners/si2157.h
index 8467d08..a564c4a 100644
--- a/drivers/media/tuners/si2157.h
+++ b/drivers/media/tuners/si2157.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2146/2147/2157/2158 silicon tuner driver
+ * Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
diff --git a/drivers/media/tuners/si2157_priv.h 
b/drivers/media/tuners/si2157_priv.h
index c1ea821..65874e0 100644
--- a/drivers/media/tuners/si2157_priv.h
+++ b/drivers/media/tuners/si2157_priv.h
@@ -1,5 +1,5 @@
 /*
- * Silicon Labs Si2146/2147/2157/2158 silicon tuner driver
+ * Silicon Labs Si2146/2147/2148/2157/2158 silicon tuner driver
  *
  * Copyright (C) 2014 Antti Palosaari cr...@iki.fi
  *
@@ -42,6 +42,7 @@ struct si2157_cmd {
unsigned rlen;
 };
 
+#define SI2148_A20_FIRMWARE dvb-tuner-si2148-a20-01.fw
 #define SI2158_A20_FIRMWARE dvb-tuner-si2158-a20-01.fw
 
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


v4l-utils: possible ir-keytable bug

2014-11-24 Thread Olli Salonen
Hi all,

I've got an issue with ir-keytable when I try to use the -d parameter
to choose the device.

I've got one device:

olli@dl160:~$ sudo ir-keytable -v
Found device /sys/class/rc/rc0/
Input sysfs node is /sys/class/rc/rc0/input18/
Event sysfs node is /sys/class/rc/rc0/input18/event2/
Parsing uevent /sys/class/rc/rc0/input18/event2/uevent
/sys/class/rc/rc0/input18/event2/uevent uevent MAJOR=13
/sys/class/rc/rc0/input18/event2/uevent uevent MINOR=66
/sys/class/rc/rc0/input18/event2/uevent uevent DEVNAME=input/event2
Parsing uevent /sys/class/rc/rc0/uevent
/sys/class/rc/rc0/uevent uevent NAME=rc-terratec-slim-2
/sys/class/rc/rc0/uevent uevent DRV_NAME=em28xx
input device is /dev/input/event2
/sys/class/rc/rc0/protocols protocol rc-5 (disabled)
/sys/class/rc/rc0/protocols protocol nec (enabled)
/sys/class/rc/rc0/protocols protocol rc-6 (disabled)
Found /sys/class/rc/rc0/ (/dev/input/event2) with:
Driver em28xx, table rc-terratec-slim-2
Supported protocols: NEC RC-5 RC-6
Enabled protocols: NEC
Name: em28xx IR (em28178 #0)
bus: 3, vendor/product: eb1a:8179, version: 0x0001
Repeat delay = 500 ms, repeat period = 125 ms

But when I try to change the protocol using the -d parameter, I get an error:

olli@dl160:~$ sudo ir-keytable -v -p RC-6 -d /dev/input/event2
Opening /dev/input/event2
Input Protocol version: 0x00010001
Invalid protocols selected
Couldn't change the IR protocols

However, if instead of -d I use -s it works fine:

olli@dl160:~$ sudo ir-keytable -v -p RC-6 -s rc0
Found device /sys/class/rc/rc0/
Input sysfs node is /sys/class/rc/rc0/input18/
Event sysfs node is /sys/class/rc/rc0/input18/event2/
Parsing uevent /sys/class/rc/rc0/input18/event2/uevent
/sys/class/rc/rc0/input18/event2/uevent uevent MAJOR=13
/sys/class/rc/rc0/input18/event2/uevent uevent MINOR=66
/sys/class/rc/rc0/input18/event2/uevent uevent DEVNAME=input/event2
Parsing uevent /sys/class/rc/rc0/uevent
/sys/class/rc/rc0/uevent uevent NAME=rc-terratec-slim-2
/sys/class/rc/rc0/uevent uevent DRV_NAME=em28xx
input device is /dev/input/event2
/sys/class/rc/rc0/protocols protocol rc-5 (disabled)
/sys/class/rc/rc0/protocols protocol nec (enabled)
/sys/class/rc/rc0/protocols protocol rc-6 (disabled)
Opening /dev/input/event2
Input Protocol version: 0x00010001
Protocols changed to RC-6

Am I doing something daft or is there an issue?

Cheers,
-olli
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] si2157: Add support for Si2148-A20

2014-11-24 Thread Olli Salonen
Moro Antti,

Allright, possibly there won't be new firmware for the previous
generation 2148/2158 anyway, who knows. Thanks for the reviews!

Cheers,
-olli

On 24 November 2014 at 15:39, Antti Palosaari cr...@iki.fi wrote:
 Moikka!
 I decided apply old crazyCat version, even I originally asked that firmware
 change! If I ever will ran problem with Si2148 / Si2158 firmware difference,
 I know who to blame ;p

 That patch could be dropped.
 PULL request already sent.

 regards
 Antti

 On 11/24/2014 08:57 AM, Olli Salonen wrote:

 The Silicon Labs Si2148 tuner works as the Si2158, but does not contain
 analog tuner. A firmware is required for the tuner. Currently the Si2158-A20
 firmware will work for Si2148-A20 as well, but as there are no guarantees
 that that will be the case in future, a unique file name is used for the
 firmware.

 The datasheet is available on manufacturer's website:
 http://www.silabs.com/Support%20Documents/TechnicalDocs/Si2148-short.pdf

 Signed-off-by: Olli Salonen olli.salo...@iki.fi


 --
 http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] dvb-usb-dvbsky: add T330 dvb-t2/t/c usb stick support

2014-11-26 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Wed, 26 Nov 2014, Nibble Max wrote:


DVBSky T330 dvb-t2/t/c usb stick:
1dvb frontend: SI2157A30(tuner), SI2168B40(demod)
2usb controller: CY7C68013A

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/usb/dvb-usb-v2/dvbsky.c | 88 +++
1 file changed, 88 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
index b6326c6..86db800 100644
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -604,6 +604,65 @@ fail_demod_device:
return ret;
}

+static int dvbsky_t330_attach(struct dvb_usb_adapter *adap)
+{
+   struct dvbsky_state *state = adap_to_priv(adap);
+   struct dvb_usb_device *d = adap_to_d(adap);
+   int ret = 0;
+   struct i2c_adapter *i2c_adapter;
+   struct i2c_client *client_demod, *client_tuner;
+   struct i2c_board_info info;
+   struct si2168_config si2168_config;
+   struct si2157_config si2157_config;
+
+   /* attach demod */
+   memset(si2168_config, 0, sizeof(si2168_config));
+   si2168_config.i2c_adapter = i2c_adapter;
+   si2168_config.fe = adap-fe[0];
+   si2168_config.ts_mode = SI2168_TS_PARALLEL | 0x40;
+   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(d-i2c_adap, info);
+   if (client_demod == NULL ||
+   client_demod-dev.driver == NULL)
+   goto fail_demod_device;
+   if (!try_module_get(client_demod-dev.driver-owner))
+   goto fail_demod_module;
+
+   /* attach tuner */
+   memset(si2157_config, 0, sizeof(si2157_config));
+   si2157_config.fe = adap-fe[0];
+   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(i2c_adapter, info);
+   if (client_tuner == NULL ||
+   client_tuner-dev.driver == NULL)
+   goto fail_tuner_device;
+   if (!try_module_get(client_tuner-dev.driver-owner))
+   goto fail_tuner_module;
+
+   state-i2c_client_demod = client_demod;
+   state-i2c_client_tuner = client_tuner;
+   return ret;
+fail_tuner_module:
+   i2c_unregister_device(client_tuner);
+fail_tuner_device:
+   module_put(client_demod-dev.driver-owner);
+fail_demod_module:
+   i2c_unregister_device(client_demod);
+fail_demod_device:
+   ret = -ENODEV;
+   return ret;
+}
+
static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name)
{
dvbsky_gpio_ctrl(d, 0x04, 1);
@@ -742,6 +801,33 @@ static struct dvb_usb_device_properties dvbsky_t680c_props 
= {
}
};

+static struct dvb_usb_device_properties dvbsky_t330_props = {
+   .driver_name = KBUILD_MODNAME,
+   .owner = THIS_MODULE,
+   .adapter_nr = adapter_nr,
+   .size_of_priv = sizeof(struct dvbsky_state),
+
+   .generic_bulk_ctrl_endpoint = 0x01,
+   .generic_bulk_ctrl_endpoint_response = 0x81,
+   .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
+
+   .i2c_algo = dvbsky_i2c_algo,
+   .frontend_attach  = dvbsky_t330_attach,
+   .init = dvbsky_init,
+   .get_rc_config= dvbsky_get_rc_config,
+   .streaming_ctrl   = dvbsky_streaming_ctrl,
+   .identify_state   = dvbsky_identify_state,
+   .exit = dvbsky_exit,
+   .read_mac_address = dvbsky_read_mac_addr,
+
+   .num_adapters = 1,
+   .adapter = {
+   {
+   .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
+   }
+   }
+};
+
static const struct usb_device_id dvbsky_id_table[] = {
{ DVB_USB_DEVICE(0x0572, 0x6831,
dvbsky_s960_props, DVBSky S960/S860, RC_MAP_DVBSKY) },
@@ -749,6 +835,8 @@ static const struct usb_device_id dvbsky_id_table[] = {
dvbsky_s960c_props, DVBSky S960CI, RC_MAP_DVBSKY) },
{ DVB_USB_DEVICE(0x0572, 0x680c,
dvbsky_t680c_props, DVBSky T680CI, RC_MAP_DVBSKY) },
+   { DVB_USB_DEVICE(0x0572, 0x0320,
+   dvbsky_t330_props, DVBSky T330, RC_MAP_DVBSKY) },
{ }
};
MODULE_DEVICE_TABLE(usb, dvbsky_id_table);

--
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] cxusb: remove TechnoTrend CT2-4400 and CT2-4650 devices

2014-11-26 Thread Olli Salonen

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Wed, 26 Nov 2014, Nibble Max wrote:


Remove TechnoTrend CT2-4400 and CT2-4650 devices from cxusb.
They are supported by dvb-usb-dvbsky driver in PATCH 3/3.

Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/usb/dvb-usb/Kconfig |   1 -
drivers/media/usb/dvb-usb/cxusb.c | 298 --
drivers/media/usb/dvb-usb/cxusb.h |   4 -
3 files changed, 303 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/Kconfig 
b/drivers/media/usb/dvb-usb/Kconfig
index 41d3eb9..3364200 100644
--- a/drivers/media/usb/dvb-usb/Kconfig
+++ b/drivers/media/usb/dvb-usb/Kconfig
@@ -130,7 +130,6 @@ config DVB_USB_CXUSB

  Medion MD95700 hybrid USB2.0 device.
  DViCO FusionHDTV (Bluebird) USB2.0 devices
- TechnoTrend TVStick CT2-4400 and CT2-4650 CI devices

config DVB_USB_M920X
tristate Uli m920x DVB-T USB2.0 support
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index 643d88f..0f345b1 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -44,7 +44,6 @@
#include atbm8830.h
#include si2168.h
#include si2157.h
-#include sp2.h

/* Max transfer size done by I2C transfer functions */
#define MAX_XFER_SIZE  80
@@ -147,22 +146,6 @@ static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device 
*d,
}
}

-static int cxusb_tt_ct2_4400_gpio_tuner(struct dvb_usb_device *d, int onoff)
-{
-   u8 o[2], i;
-   int rc;
-
-   o[0] = 0x83;
-   o[1] = onoff;
-   rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, i, 1);
-
-   if (rc) {
-   deb_info(gpio_write failed.\n);
-   return -EIO;
-   }
-   return 0;
-}
-
/* I2C */
static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
  int num)
@@ -524,30 +507,6 @@ static int cxusb_d680_dmb_rc_query(struct dvb_usb_device 
*d, u32 *event,
return 0;
}

-static int cxusb_tt_ct2_4400_rc_query(struct dvb_usb_device *d)
-{
-   u8 i[2];
-   int ret;
-   u32 cmd, keycode;
-   u8 rc5_cmd, rc5_addr, rc5_toggle;
-
-   ret = cxusb_ctrl_msg(d, 0x10, NULL, 0, i, 2);
-   if (ret)
-   return ret;
-
-   cmd = (i[0]  8) | i[1];
-
-   if (cmd != 0x) {
-   rc5_cmd = cmd  0x3F; /* bits 1-6 for command */
-   rc5_addr = (cmd  0x07C0)  6; /* bits 7-11 for address */
-   rc5_toggle = (cmd  0x0800)  11; /* bit 12 for toggle */
-   keycode = (rc5_addr  8) | rc5_cmd;
-   rc_keydown(d-rc_dev, RC_BIT_RC5, keycode, rc5_toggle);
-   }
-
-   return 0;
-}
-
static struct rc_map_table rc_map_dvico_mce_table[] = {
{ 0xfe02, KEY_TV },
{ 0xfe0e, KEY_MP3 },
@@ -673,70 +632,6 @@ static struct rc_map_table rc_map_d680_dmb_table[] = {
{ 0x0025, KEY_POWER },
};

-static int cxusb_tt_ct2_4400_read_mac_address(struct dvb_usb_device *d, u8 
mac[6])
-{
-   u8 wbuf[2];
-   u8 rbuf[6];
-   int ret;
-   struct i2c_msg msg[] = {
-   {
-   .addr = 0x51,
-   .flags = 0,
-   .buf = wbuf,
-   .len = 2,
-   }, {
-   .addr = 0x51,
-   .flags = I2C_M_RD,
-   .buf = rbuf,
-   .len = 6,
-   }
-   };
-
-   wbuf[0] = 0x1e;
-   wbuf[1] = 0x00;
-   ret = cxusb_i2c_xfer(d-i2c_adap, msg, 2);
-
-   if (ret == 2) {
-   memcpy(mac, rbuf, 6);
-   return 0;
-   } else {
-   if (ret  0)
-   return ret;
-   return -EIO;
-   }
-}
-
-static int cxusb_tt_ct2_4650_ci_ctrl(void *priv, u8 read, int addr,
-   u8 data, int *mem)
-{
-   struct dvb_usb_device *d = priv;
-   u8 wbuf[3];
-   u8 rbuf[2];
-   int ret;
-
-   wbuf[0] = (addr  8)  0xff;
-   wbuf[1] = addr  0xff;
-
-   if (read) {
-   ret = cxusb_ctrl_msg(d, CMD_SP2_CI_READ, wbuf, 2, rbuf, 2);
-   } else {
-   wbuf[2] = data;
-   ret = cxusb_ctrl_msg(d, CMD_SP2_CI_WRITE, wbuf, 3, rbuf, 1);
-   }
-
-   if (ret)
-   goto err;
-
-   if (read)
-   *mem = rbuf[1];
-
-   return 0;
-err:
-   deb_info(%s: ci usb write returned %d\n, __func__, ret);
-   return ret;
-
-}
-
static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
{
static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x28 };
@@ -1478,127 +1373,6 @@ static int cxusb_mygica_t230_frontend_attach(struct 
dvb_usb_adapter *adap)
return 0;
}

-static int cxusb_tt_ct2_4400_attach(struct dvb_usb_adapter *adap)
-{
-   struct dvb_usb_device *d = adap-dev;
-   struct cxusb_state *st = d-priv;
-   struct i2c_adapter *adapter;
-   struct i2c_client *client_demod

Re: [PATCH 3/3] dvb-usb-dvbsky: add TechnoTrend CT2-4400 and CT2-4650 devices support

2014-11-26 Thread Olli Salonen

On Wed, 26 Nov 2014, Nibble Max wrote:


Signed-off-by: Nibble Max nibble@gmail.com
---
drivers/media/usb/dvb-usb-v2/dvbsky.c | 8 
1 file changed, 8 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c


Hi Max,

I tested your patch with Technotrend CT2-4400v2 and CT2-4650 CI. Seems to 
work ok and the code looks ok for me as well.


Reviewed-by: Olli Salonen olli.salo...@iki.fi
Tested-by: Olli Salonen olli.salo...@iki.fi

Cheers,
-olli

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] si2168: debug printout for firmware version

2014-11-27 Thread Olli Salonen
A debug printout for firmware version.

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index bec3aa5..6da38e8 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -489,6 +489,17 @@ static int si2168_init(struct dvb_frontend *fe)
if (ret)
goto err;
 
+   /* query firmware version */
+   memcpy(cmd.args, \x11, 1);
+   cmd.wlen = 1;
+   cmd.rlen = 10;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret)
+   goto err;
+
+   dev_dbg(s-client-dev, firmware version: %c.%c.%d\n,
+   cmd.args[6], cmd.args[7], cmd.args[8]);
+
/* set ts mode */
memcpy(cmd.args, \x14\x00\x01\x10\x10\x00, 6);
cmd.args[4] |= s-ts_mode;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] si2168: add support for firmware files in new format

2014-11-27 Thread Olli Salonen
This patch adds support for new type of firmware versions of Si2168 chip. 

Old type: n x 8 bytes (all data, first byte seems to be 04 or 05)
New type: n x 17 bytes (1 byte indicates len and max 16 bytes data)

New version of TechnoTrend CT2-4400 drivers 
(http://www.tt-downloads.de/bda-treiber_4.3.0.0.zip) contains newer
firmware for Si2168-B40 that is in the new format. It can be extracted
with the following command:

dd if=ttTVStick4400_64.sys ibs=1 skip=323872 count=6919 
of=dvb-demod-si2168-b40-01.fw

Signed-off-by: Olli Salonen olli.salo...@iki.fi
---
 drivers/media/dvb-frontends/si2168.c | 46 +---
 1 file changed, 32 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2168.c 
b/drivers/media/dvb-frontends/si2168.c
index 6da38e8..ce9ab44 100644
--- a/drivers/media/dvb-frontends/si2168.c
+++ b/drivers/media/dvb-frontends/si2168.c
@@ -462,20 +462,38 @@ static int si2168_init(struct dvb_frontend *fe)
dev_info(s-client-dev, downloading firmware from file '%s'\n,
fw_file);
 
-   for (remaining = fw-size; remaining  0; remaining -= i2c_wr_max) {
-   len = remaining;
-   if (len  i2c_wr_max)
-   len = i2c_wr_max;
-
-   memcpy(cmd.args, fw-data[fw-size - remaining], len);
-   cmd.wlen = len;
-   cmd.rlen = 1;
-   ret = si2168_cmd_execute(s, cmd);
-   if (ret) {
-   dev_err(s-client-dev,
-   firmware download failed=%d\n,
-   ret);
-   goto error_fw_release;
+   if ((fw-size % 17 == 0)  (fw-data[0]  5)) {
+   /* firmware is in the new format */
+   for (remaining = fw-size; remaining  0; remaining -= 17) {
+   len = fw-data[fw-size - remaining];
+   memcpy(cmd.args, fw-data[(fw-size - remaining) + 1], 
len);
+   cmd.wlen = len;
+   cmd.rlen = 1;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret) {
+   dev_err(s-client-dev,
+   firmware download failed=%d\n,
+   ret);
+   goto error_fw_release;
+   }
+   }
+   } else {
+   /* firmware is in the old format */
+   for (remaining = fw-size; remaining  0; remaining -= 
i2c_wr_max) {
+   len = remaining;
+   if (len  i2c_wr_max)
+   len = i2c_wr_max;
+
+   memcpy(cmd.args, fw-data[fw-size - remaining], len);
+   cmd.wlen = len;
+   cmd.rlen = 1;
+   ret = si2168_cmd_execute(s, cmd);
+   if (ret) {
+   dev_err(s-client-dev,
+   firmware download failed=%d\n,
+   ret);
+   goto error_fw_release;
+   }
}
}
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Terratec H7 with yet another usb ID

2014-12-06 Thread Olli Salonen
Hi Eddi,

As far as I know, the new version of Terratec H7 is another version of
DVBSky T680CI or TechnoTrend CT2-4650 CI. Just try to change the USB
IDs in the dvbsky.c driver and compile the driver and test. I'd do
this for you, but am travelling at the moment and have very limited
time.

Cheers,
-olli

On 5 December 2014 at 23:27, Eddi De Pieri e...@depieri.net wrote:
 Hi Rik,


 I've download Terratec H7 rev 4 should be a
 TechnoTrend_TT-TVStick_CT2-44xx clone so you could try to patch
 dvbsky.c driver.

 Strings inside the windows driver:
 T E R R A T E C   S 7   D i g i t a l   T u n e r   ( D V B - S / S 2 )
 T T - c o n n e c t   C T 2 _ 4 6 5 0   D V B - T / T 2   T u n e r
 T E R R A T E C   H 7   D i g i t a l   T u n e r   ( D V B - T / T 2 )
 T T - c o n n e c t   C T 2 _ 4 6 5 0   D V B - C   T u n e r
 T E R R A T E C   H 7   D i g i t a l   T u n e r   ( D V B - C )

 Regards...
 Eddi

 On Fri, Dec 5, 2014 at 4:11 PM, Antti Palosaari cr...@iki.fi wrote:
 Moikka
 Take USB sniffs and generate driver C-code from that sniff. Then copypaste
 that code to driver until is starts working. After that, you could remove
 all the code until you find minimum set of needed changes (error and trial).

 regards
 Antti


 On 12/05/2014 04:51 PM, Eddi De Pieri wrote:

 Hi,

 I got a sample usb tuner with similar issue with following
 vendor/product 13d3:0ccd.

 Onboard it have: CY7C68013A-56PVXC and a SI2168-40. The tuner isn't
 visible since is covered by a shield.

 I've tried to patch the az6007 to make it working.

 si2168 4-0064: Silicon Labs Si2168 successfully attached
 si2157 5-0060: unknown chip version Si2147-A30

 after applying latest patch from patchwork:

 si2157 5-0060: Silicon Labs Si2157/Si2158 successfully attached

 Now tuner seems to be connected but a w_scan don't detect any channel...

 Can you give me some some hint on troubleshooting this issue?

 Actually I'm brutally changed the initialization with copy and paste
 of silab attach from cxusb.c and em28xx-dvb.c by removing the drxk
 init..

 Since the chinese producer recicled old vid/pid.but what is the
 correct way to probe for multiple frontend and choose the right one?

 Eddi


 On Mon, Feb 3, 2014 at 11:33 PM, Antti Palosaari cr...@iki.fi wrote:

 Hei Rik


 On 03.02.2014 22:21, Rik van Mierlo wrote:


 Hi,

 I've recently purchased a Terratec H7, based on the fact that is was
 supported for a while now. Unfortunately, it turns out that my device
 uses a different product id, and maybe is not quite the same device
 inside either.

 ProductID for the Terratec H7 revisions in the module is either 10b4 or
 10a3, the one I purchased is 10a5. Following this patch:

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

 I modified drivers/media/usb/dvb-usb-v2/az6007.c to include an
 additional device:

 static struct usb_device_id az6007_usb_table[] = {
   {DVB_USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_6007,
   az6007_props, Azurewave 6007, RC_MAP_EMPTY)},
   {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7,
   az6007_props, Terratec H7,
 RC_MAP_NEC_TERRATEC_CINERGY_XS)},
   {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7_2,
   az6007_props, Terratec H7,
 RC_MAP_NEC_TERRATEC_CINERGY_XS)},
   {DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_H7_3,
   az6007_props, Terratec H7,
 RC_MAP_NEC_TERRATEC_CINERGY_XS)},
   {DVB_USB_DEVICE(USB_VID_TECHNISAT,
 USB_PID_TECHNISAT_USB2_CABLESTAR_HDCI,
   az6007_cablestar_hdci_props, Technisat CableStar
 Combo HD CI, RC_MAP_EMPTY)},
   {0},
 };

 and added the following to drivers/media/dvb-core/dvb-usb-ids.h

 #define USB_PID_TERRATEC_H7_3   0x10a5

 and recompiled/installed the kernel and modules. The module seems to
 have changed somewhat in 3.12.6 from the version that the patch was
 meant for, so I hope I this was all I had to change.

 Rebooting and plugging in the device now at least leads to a recognized
 device, but scanning for channels with w_scan does not work, and from
 the dmesg output below, it seems something is not working after loading
 the drxk firmware. Does anybody know what I could try next to get this
 device working? Could it be that the drxk firmware is not suitable for
 this revision of the device?

 [  700.112072] usb 4-2: new high-speed USB device number 2 using
 ehci-pci
 [  700.245092] usb 4-2: New USB device found, idVendor=0ccd,
 idProduct=10a5
 [  700.245105] usb 4-2: New USB device strings: Mfr=1, Product=2,
 SerialNumber=3
 [  700.245114] usb 4-2: Product: TERRATEC T2/T/C CI USB
 [  700.245123] usb 4-2: Manufacturer: TERRATEC
 [  700.245131] usb 4-2: SerialNumber: 20130903
 [  700.494693] usb read operation failed. (-32)
 [  700.495039] usb write operation failed. (-32)
 [  700.495413] usb write operation failed. (-32)
 [  700.495787] usb write operation failed. (-32)



 These low level errors does not 

Re: TT-connect CT2-4650 CI: DVB-C: no signal, no QAM

2014-12-08 Thread Olli Salonen
Hi Pavol,

Thanks. As said, I have not had any time to look into this, but will
definitely do so. I own the same device, but do not have cable TV at
home. Am using Conax CAM also successfully, so I believe that CI is
not the issue.

Some things that came to my mind still:

Can you share the results of w_scan with very verbose output with both
TT driver and the kernel driver? Also, make sure you use a recent
version of w_scan - some distributions come with a rather old
version...

w_scan -v -v -v your_options_here 21 | tee logfile.txt

Also, if you want to try a later firmware for Si2168, have a look at this patch:
http://git.linuxtv.org/cgit.cgi/media_tree.git/commit/?id=1b97dc98b58dad98f13fa0a4cdc819b60f3f3bff

It is in media_tree already.

Cheers,
-olli


On 8 December 2014 at 18:56, Pavol Domin pavol.do...@gmail.com wrote:
 Hi Olli,

 Thanks for feedback.
 Are you able to provide me a trace of the USB bus when using Windows? This
 is what I have been doing.

 1) install USBlyzer
 2) start it and select the option Capture hot plugged in the menus
 3) start capture
 4) plug in the device
 5) start watching tv
 6) stop capture after 1 sec to avoid the capture file growing too much
 I've done that and shared at:
 https://drive.google.com/open?id=0B94Ll0t460PoSTdKR0xiZlU2S0Eauthuser=0

 Would be also good to know if gnutv -cammenu works with the open source
 Yes, it seems to work (except it coredumps after ctrl-c on fedora), e.g.
 $ gnutv -channels channels.xine.conf -cammenu Eurosport HD
 CAM Application type: 01
 CAM Application manufacturer: 0b00
 CAM Manufacturer code: 0001
 CAM Menu string: Conax Conditional Access
 CAM supports the following ca system ids:
   0x0b00
   --
   Conax Conditional Access
   Main menu
   0. Quit menu
   1. Subscription status
   2. Event status
   3. Tokens status
   4. Change CA PIN
   5. Maturity Rating
   6. Ordering online
   7. About Conax CA
   8. Messages
   9. Language
   10. Loader status
   11. CI Plus Info
   Press OK to select, or press RETURN

 driver. Are all your channels encrypted? Is there any difference between
 them?
 No, some are unencrypted. I cannot tell there are some other
 differences, windows application 'tt-viewer' does not show details
 about scanned channels. Also, the multiplex frequencies listed by
 provider do not seem to match much with what the w_scan initially found.
 Also, w_scan only scanned at QAM256, tv provider page suggests there are
 some channels at QAM64 (I havent tried to scan those).
 But again, it worked (with the TechnoTrend driver) for a short while
 from linux, even the encryted channels I think.

 Regards

 Pavol


 Cheers,
 -olli
 On 7 Dec 2014 19:41, Pavol Domin pavol.do...@gmail.com wrote:

  Hello,
 
  I recently purchased TechnoTrend TT-connect CT2-4650 CI in order to
  watch DVB-C cable TV. I have obtained CAM and smart card from my cable
  TV provider.
 
  Initially, I tried the closed-source driver from the manufacturer; I have
  scanned (w_scan) over hundred of channels and I was able to watch few
  channels (vlc
  or xine) for several minutes. After couple of channels switches however,
  xine started to report 'DVB Signal Lost' for any channel. The w_scan
  founds nothing anymore - tried multiple kernels on different machines,
  during several days, nothing ;)
 
  Manufacturer is not providing linux support and directed me to
  linux_media instead.
 
  The situation with linux_media is not better however (tried recent
  media_build on ubuntu 3.16 and fedora 3.17 kernels)
 
  1. the device is detected without any problems, no single error reported:
  [ 1957.068871] dvb-usb: found a 'TechnoTrend TT-connect CT2-4650 CI' in
  warm state.
  [ 1957.068999] dvb-usb: will pass the complete MPEG2 transport stream to
  the software demuxer.
  [ 1957.069182] DVB: registering new adapter (TechnoTrend TT-connect
  CT2-4650 CI)
  [ 1957.070518] dvb-usb: MAC address: bc:ea:2b:65:02:3b
  [ 1957.283195] i2c i2c-9: Added multiplexed i2c bus 10
  [ 1957.283205] si2168 9-0064: Silicon Labs Si2168 successfully attached
  [ 1957.287689] si2157 10-0060: Silicon Labs Si2147/2148/2157/2158
  successfully attached
  [ 1957.498312] sp2 9-0040: CIMaX SP2 successfully attached
  [ 1957.498348] usb 1-1.3: DVB: registering adapter 0 frontend 0 (Silicon
  Labs Si2168)...
  [ 1957.498835] Registered IR keymap rc-tt-1500
  [ 1957.499038] input: IR-receiver inside an USB DVB receiver as
  /devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0/input23
  [ 1957.499408] rc0: IR-receiver inside an USB DVB receiver as
  /devices/pci:00/:00:1a.0/usb1/1-1/1-1.3/rc/rc0
  [ 1957.499413] dvb-usb: schedule remote query interval to 150 msecs.
  [ 1957.499419] dvb-usb: TechnoTrend TT-connect CT2-4650 CI successfully
  initialized and connected.
  [ 1963.73] dvb_ca adapter 0: DVB CAM detected and initialised
  successfully
  [ 2016.342642] si2168 9-0064: found a 'Silicon Labs Si2168' in cold state
  [ 2016.342910] si2168 

Re: dvbv5-scan needs which channel file?

2014-12-29 Thread Olli Salonen
Hello David,

Coincidentally I was just yesterday working with dvbv5-scan and the
initial scan files. dvbv5-scan expects the initial scan files in the
new DVBV5 format. w_scan is not producing results in this format.

The scan tables at
http://git.linuxtv.org/cgit.cgi/dtv-scan-tables.git/ are in the new
format. Some of them are a bit outdated though (send in a patch if you
can update it for your area).

The v4l-utils package also includes tools to convert between the old
and the new format.

Cheers,
-olli


On 29 December 2014 at 22:09, David Liontooth lionte...@cogweb.net wrote:

 Greetings --

 How do you actually use dvbv5-scan? It seems to require some kind of input
 file but there is no man page and the --help screen doesn't say anything
 about it.

 Could we document this? I tried

 $ dvbv5-scan
 Usage: dvbv5-scan [OPTION...] initial file
 scan DVB services using the channel file

 What is the channel file? Maybe the channels.conf file? (I created mine
 using w_scan -ft -A3 -X -cUS -o7 -a /dev/dvb/adapter0/)

 $ dvbv5-scan /etc/channels.conf
 ERROR key/value without a channel group while parsing line 1 of
 /etc/channels.conf

 So it knows what it wants -- but what is it? Or is this a matter of dvb
 versions, and my /etc/channels.conf is in the older format?

 Very mysterious.

 Cheers,
 David
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: dvbv5-scan needs which channel file?

2014-12-30 Thread Olli Salonen
Hi David,

Well, the initial scan files need to be supplied for dvbv5-scan somehow.

The initial scan files that are maintained in the the git repo I
posted earlier are updated by users who notice differencies. Basically
I and some other users have created scripts that automatically
generate the files for my country, so it's rather easy. I don't know
how it works for other countries.

Anyway, if you prefer to generate the data yourself you can use w_scan
to generate it in DVBV3 format:
w_scan -ft -c FI -x  ~/initial_v3.conf

Then use the dvb-format-convert tool that comes in the v4l-utils package:
dvb-format-convert -I CHANNEL -O DVBV5 ~/initial_v3.conf ~/initial_data_v5.conf

Then you can run dvbv5-scan with this file:
dvbv5-scan ~/initial_data_v5.conf

Alternatively you can skip the whole conversion phase and run
dvbv5-scan with the DVBV3 initial tuning data:
dvbv5-scan -I CHANNEL ~/initial_v3.conf

Cheers,
-olli

On 30 December 2014 at 10:23, David Liontooth lionte...@cogweb.net wrote:

 Ah, thank you Olli -- much appreciated!

 If dvbv5-scan expects the initial scan files in the new DVBV5 format, does
 that mean that these still somewhat mysterious initial scan files have to
 be supplied, as in the link to the dtv-scan-tables? How are these initial
 scan files themselves generated?

 Surely there must be thousands of different dvb signal locations -- is
 linux-tv going to try to maintain these thousands of scan tables for
 download? What do users do when their particular location is not represented
 in the dtv-scan-tables.git?

 Finally, I'm using gnutv to record television; I imagine it still only
 accepts the old format? What's the new alternative?

 Cheers,
 David

 On 12/29/14, 11:55 PM, Olli Salonen wrote:

 Hello David,

 Coincidentally I was just yesterday working with dvbv5-scan and the
 initial scan files. dvbv5-scan expects the initial scan files in the
 new DVBV5 format. w_scan is not producing results in this format.

 The scan tables at
 http://git.linuxtv.org/cgit.cgi/dtv-scan-tables.git/ are in the new
 format. Some of them are a bit outdated though (send in a patch if you
 can update it for your area).

 The v4l-utils package also includes tools to convert between the old
 and the new format.

 Cheers,
 -olli


 On 29 December 2014 at 22:09, David Liontooth lionte...@cogweb.net
 wrote:

 Greetings --

 How do you actually use dvbv5-scan? It seems to require some kind of
 input
 file but there is no man page and the --help screen doesn't say anything
 about it.

 Could we document this? I tried

 $ dvbv5-scan
 Usage: dvbv5-scan [OPTION...] initial file
 scan DVB services using the channel file

 What is the channel file? Maybe the channels.conf file? (I created mine
 using w_scan -ft -A3 -X -cUS -o7 -a /dev/dvb/adapter0/)

 $ dvbv5-scan /etc/channels.conf
 ERROR key/value without a channel group while parsing line 1 of
 /etc/channels.conf

 So it knows what it wants -- but what is it? Or is this a matter of dvb
 versions, and my /etc/channels.conf is in the older format?

 Very mysterious.

 Cheers,
 David
 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

 --
 To unsubscribe from this list: send the line unsubscribe linux-media in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fix Mygica T230 support

2015-01-02 Thread Olli Salonen

Indeed, good catch. Mauro, this should go into 3.19.

Reviewed-by: Olli Salonen olli.salo...@iki.fi

On Fri, 2 Jan 2015, Jonathan McDowell wrote:


Commit 2adb177e57417cf8409e86bda2c516e5f99a2099 removed 2 devices
from the cxusb device table but failed to fix up the T230 properties
that follow, meaning that this device no longer gets detected properly.
Adjust the cxusb_table index appropriate so detection works.

Signed-Off-By: Jonathan McDowell nood...@earth.li

-
diff --git a/drivers/media/usb/dvb-usb/cxusb.c 
b/drivers/media/usb/dvb-usb/cxusb.c
index 0f345b1..f327c49 100644
--- a/drivers/media/usb/dvb-usb/cxusb.c
+++ b/drivers/media/usb/dvb-usb/cxusb.c
@@ -2232,7 +2232,7 @@ static struct dvb_usb_device_properties 
cxusb_mygica_t230_properties = {
{
Mygica T230 DVB-T/T2/C,
{ NULL },
-   { cxusb_table[22], NULL },
+   { cxusb_table[20], NULL },
},
}
};

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   3   >