diff mbox

[5/5] saa7164: Hauppauge HVR-2205 and HVR-2215 DVB-C/T/T2 tuners

Message ID 1427457439-1493-5-git-send-email-olli.salonen@iki.fi (mailing list archive)
State New, archived
Headers show

Commit Message

Olli Salonen March 27, 2015, 11:57 a.m. UTC
Hauppauge HVR-2205 and HVR-2215 are PCIe dual tuner cards that support
DVB-C, DVB-T and DVB-T2.

PCIe bridge: SAA7164
Demodulator: Si2168-B40
Tuner: SI2157-A20

I know there's parallel activity ongoing regarding these devices, but I 
thought I'll submit my own version here as well. The maintainers of each 
module can then make the call what to merge.

Signed-off-by: Olli Salonen <olli.salonen@iki.fi>
---
 drivers/media/pci/saa7164/Kconfig         |   2 +
 drivers/media/pci/saa7164/saa7164-cards.c | 101 ++++++++++++++++++++++++++++++
 drivers/media/pci/saa7164/saa7164-dvb.c   |  67 ++++++++++++++++++++
 drivers/media/pci/saa7164/saa7164.h       |   2 +
 4 files changed, 172 insertions(+)

Comments

Steven Toth March 27, 2015, 12:08 p.m. UTC | #1
> I know there's parallel activity ongoing regarding these devices, but I
> thought I'll submit my own version here as well. The maintainers of each
> module can then make the call what to merge.

http://git.linuxtv.org/cgit.cgi/stoth/media_tree.git/log/?h=saa7164-dev

As mentioned previously, I've added support for the HVR2205 and
HVR2255. I moved those patches from bitbucket.org into linuxtv.org a
couple of days ago pending a pull request. It took a couple of days to
get my git.linuxtv.org account back up and running.

You've seen and commented on the patches when they were in bitbucket
earlier this week, so your need to push our your own patches only
confuses and concerns me.

I did not require any 2168/2157 driver changes to make these devices
work. (Antti please note).

I plan to issue a pull request for my tree shortly.

- Steve
Antti Palosaari March 27, 2015, 12:13 p.m. UTC | #2
On 03/27/2015 02:08 PM, Steven Toth wrote:
>> I know there's parallel activity ongoing regarding these devices, but I
>> thought I'll submit my own version here as well. The maintainers of each
>> module can then make the call what to merge.
>
> http://git.linuxtv.org/cgit.cgi/stoth/media_tree.git/log/?h=saa7164-dev
>
> As mentioned previously, I've added support for the HVR2205 and
> HVR2255. I moved those patches from bitbucket.org into linuxtv.org a
> couple of days ago pending a pull request. It took a couple of days to
> get my git.linuxtv.org account back up and running.
>
> You've seen and commented on the patches when they were in bitbucket
> earlier this week, so your need to push our your own patches only
> confuses and concerns me.
>
> I did not require any 2168/2157 driver changes to make these devices
> work. (Antti please note).

There seems to be only minor TS config change (which is not even needed 
if you set that bit to existing TS mode config value) for 
gapped/variable length TS clock (which is in my understanding to leave 
TS valid line unconnected).

> I plan to issue a pull request for my tree shortly.
>
> - Steve
>

Antti
Steven Toth March 27, 2015, 12:16 p.m. UTC | #3
>> I did not require any 2168/2157 driver changes to make these devices
>> work. (Antti please note).
>
>
> There seems to be only minor TS config change (which is not even needed if
> you set that bit to existing TS mode config value) for gapped/variable
> length TS clock (which is in my understanding to leave TS valid line
> unconnected).

Its not required for the HVR2205 or the HVR2255, these are the only
two models of the hardware shipping in production volumes to
customers. Any other cards were advanced prototypes, that's my
understanding.

I'm not suggesting the gapped clock 2168 patch isn't useful for other
bridges, you might want to pull Olli's patch for that, but its not
required for the HVR2205/2255 support.
Olli Salonen March 27, 2015, 12:31 p.m. UTC | #4
Hi,

Feel free to ignore the patches I sent. Just thought that since I made
the work to get the devices working anyway I'll post my code in case
someone can benefit from that somehow.

The HVR-2215 is sold in Australia, it's not a prototype card:
http://www.pccasegear.com/index.php?main_page=product_info&products_id=28385&cPath=172

I also know a user in AU who has tested my code with HVR-2215 and it works ok.

My understanding is that the Windows driver does set the gapped clock,
the below is from Hauppauge's own Windows driver INF files for
HVR-2205 (I assume the parameters pointing to Si2164 apply also to
Si2168):

;gapped clock
HKR,"Parameters","Si2164_ts_clk_gapped_en",0x00010001, 1

However, it is true that the device seems to work with or without this
setting. That was the case with TechnoTrend CT2-4400 earlier as well.
Only when TT made another version of the same device (with the same
USB IDs etc.) it stopped working and the change was necessary.

Cheers,
-olli


On 27 March 2015 at 14:08, Steven Toth <stoth@kernellabs.com> wrote:
>> I know there's parallel activity ongoing regarding these devices, but I
>> thought I'll submit my own version here as well. The maintainers of each
>> module can then make the call what to merge.
>
> http://git.linuxtv.org/cgit.cgi/stoth/media_tree.git/log/?h=saa7164-dev
>
> As mentioned previously, I've added support for the HVR2205 and
> HVR2255. I moved those patches from bitbucket.org into linuxtv.org a
> couple of days ago pending a pull request. It took a couple of days to
> get my git.linuxtv.org account back up and running.
>
> You've seen and commented on the patches when they were in bitbucket
> earlier this week, so your need to push our your own patches only
> confuses and concerns me.
>
> I did not require any 2168/2157 driver changes to make these devices
> work. (Antti please note).
>
> I plan to issue a pull request for my tree shortly.
>
> - Steve
>
> --
> Steven Toth - Kernel Labs
> http://www.kernellabs.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steven Toth March 27, 2015, 12:39 p.m. UTC | #5
> The HVR-2215 is sold in Australia, it's not a prototype card:
> http://www.pccasegear.com/index.php?main_page=product_info&products_id=28385&cPath=172

Thanks for the URL. I've ordered a card. I'll look into the gapped
clock. If it's not required on the HVR2205 (using 2168) then it
shouldn't be required for the HVR2215 (using 2168), but that's
speculation at this point.

I also have the hardware schematics so I'll check those when the board
arrives also.

Thanks for the heads up.
diff mbox

Patch

diff --git a/drivers/media/pci/saa7164/Kconfig b/drivers/media/pci/saa7164/Kconfig
index a53db7d..5ebe930 100644
--- a/drivers/media/pci/saa7164/Kconfig
+++ b/drivers/media/pci/saa7164/Kconfig
@@ -8,7 +8,9 @@  config VIDEO_SAA7164
 	select VIDEOBUF_DVB
 	select DVB_TDA10048 if MEDIA_SUBDRV_AUTOSELECT
 	select DVB_S5H1411 if MEDIA_SUBDRV_AUTOSELECT
+	select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
 	select MEDIA_TUNER_TDA18271 if MEDIA_SUBDRV_AUTOSELECT
+	select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
 	---help---
 	  This is a video4linux driver for NXP SAA7164 based
 	  TV cards.
diff --git a/drivers/media/pci/saa7164/saa7164-cards.c b/drivers/media/pci/saa7164/saa7164-cards.c
index 5b72da5..5ebd312 100644
--- a/drivers/media/pci/saa7164/saa7164-cards.c
+++ b/drivers/media/pci/saa7164/saa7164-cards.c
@@ -499,6 +499,90 @@  struct saa7164_board saa7164_boards[] = {
 			.i2c_reg_len	= REGLEN_8bit,
 		} },
 	},
+	[SAA7164_BOARD_HAUPPAUGE_HVR2205] = {
+		.name		= "Hauppauge WinTV-HVR2205",
+		.porta		= SAA7164_MPEG_DVB,
+		.portb		= SAA7164_MPEG_DVB,
+		.chiprev	= SAA7164_CHIP_REV3,
+		.unit = {{
+			.id = 0x28,
+			.type = SAA7164_UNIT_EEPROM,
+			.name = "4K EEPROM",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_0,
+			.i2c_bus_addr	= 0xa0 >> 1,
+			.i2c_reg_len	= REGLEN_8bit,
+		}, {
+			.id		= 0x04,
+			.type		= SAA7164_UNIT_TUNER,
+			.name		= "SI2157-1",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_1,
+			.i2c_bus_addr	= 0xc0 >> 1,
+			.i2c_reg_len	= 0,
+		}, {
+			.id		= 0x05,
+			.type		= SAA7164_UNIT_DIGITAL_DEMODULATOR,
+			.name		= "SI2168-1",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_1,
+			.i2c_bus_addr	= 0xc8 >> 1,
+			.i2c_reg_len	= 0,
+		}, {
+			.id		= 0x25,
+			.type		= SAA7164_UNIT_TUNER,
+			.name		= "SI2157-2",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_2,
+			.i2c_bus_addr	= 0xc0 >> 1,
+			.i2c_reg_len	= 0,
+		}, {
+			.id		= 0x26,
+			.type		= SAA7164_UNIT_DIGITAL_DEMODULATOR,
+			.name		= "SI2168-2",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_2,
+			.i2c_bus_addr	= 0xcc >> 1,
+			.i2c_reg_len	= 0,
+		} },
+	},
+	[SAA7164_BOARD_HAUPPAUGE_HVR2215] = {
+		.name		= "Hauppauge WinTV-HVR2215",
+		.porta		= SAA7164_MPEG_DVB,
+		.portb		= SAA7164_MPEG_DVB,
+		.chiprev	= SAA7164_CHIP_REV3,
+		.unit = {{
+			.id = 0x28,
+			.type = SAA7164_UNIT_EEPROM,
+			.name = "4K EEPROM",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_0,
+			.i2c_bus_addr	= 0xa0 >> 1,
+			.i2c_reg_len	= REGLEN_8bit,
+		}, {
+			.id		= 0x04,
+			.type		= SAA7164_UNIT_TUNER,
+			.name		= "SI2157-1",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_1,
+			.i2c_bus_addr	= 0xc0 >> 1,
+			.i2c_reg_len	= 0,
+		}, {
+			.id		= 0x05,
+			.type		= SAA7164_UNIT_DIGITAL_DEMODULATOR,
+			.name		= "SI2168-1",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_1,
+			.i2c_bus_addr	= 0xc8 >> 1,
+			.i2c_reg_len	= 0,
+		}, {
+			.id		= 0x25,
+			.type		= SAA7164_UNIT_TUNER,
+			.name		= "SI2157-2",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_2,
+			.i2c_bus_addr	= 0xc0 >> 1,
+			.i2c_reg_len	= 0,
+		}, {
+			.id		= 0x26,
+			.type		= SAA7164_UNIT_DIGITAL_DEMODULATOR,
+			.name		= "SI2168-2",
+			.i2c_bus_nr	= SAA7164_I2C_BUS_2,
+			.i2c_bus_addr	= 0xcc >> 1,
+			.i2c_reg_len	= 0,
+		} },
+	},
 };
 const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
 
@@ -546,6 +630,14 @@  struct saa7164_subid saa7164_subids[] = {
 		.subvendor = 0x0070,
 		.subdevice = 0x8953,
 		.card      = SAA7164_BOARD_HAUPPAUGE_HVR2200_5,
+	}, {
+		.subvendor = 0x0070,
+		.subdevice = 0xf120,
+		.card      = SAA7164_BOARD_HAUPPAUGE_HVR2205,
+	}, {
+		.subvendor = 0x0070,
+		.subdevice = 0xf123,
+		.card      = SAA7164_BOARD_HAUPPAUGE_HVR2215,
 	},
 };
 const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
@@ -591,6 +683,8 @@  void saa7164_gpio_setup(struct saa7164_dev *dev)
 	case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
+	case SAA7164_BOARD_HAUPPAUGE_HVR2205:
+	case SAA7164_BOARD_HAUPPAUGE_HVR2215:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
@@ -647,6 +741,11 @@  static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
 		/* WinTV-HVR2200 (PCIe, Retail, half-height)
 		 * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
 		break;
+	case 151009:
+	case 151609:
+		/* WinTV-HVR2205/HVR2215 (PCIe, Retail, full-height bracket)
+		 * DVB-T2/C (Si2157/Si2168) and basic analog, FM */
+		break;
 	default:
 		printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
 			dev->name, tv.model);
@@ -673,6 +772,8 @@  void saa7164_card_setup(struct saa7164_dev *dev)
 	case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
+	case SAA7164_BOARD_HAUPPAUGE_HVR2205:
+	case SAA7164_BOARD_HAUPPAUGE_HVR2215:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c
index 6b9e8f6..2242ef5 100644
--- a/drivers/media/pci/saa7164/saa7164-dvb.c
+++ b/drivers/media/pci/saa7164/saa7164-dvb.c
@@ -24,6 +24,8 @@ 
 #include "tda10048.h"
 #include "tda18271.h"
 #include "s5h1411.h"
+#include "si2168.h"
+#include "si2157.h"
 
 #define DRIVER_NAME "saa7164"
 
@@ -519,6 +521,71 @@  int saa7164_dvb_register(struct saa7164_port *port)
 			break;
 		}
 		break;
+	case SAA7164_BOARD_HAUPPAUGE_HVR2205:
+	case SAA7164_BOARD_HAUPPAUGE_HVR2215:
+		{
+			struct si2168_config si2168_config;
+			struct si2157_config si2157_config;
+			struct i2c_board_info info;
+			struct i2c_adapter *adapter;
+			struct i2c_client *client_demod = NULL;
+			struct i2c_client *client_tuner = NULL;
+
+			i2c_bus = &dev->i2c_bus[port->nr + 1];
+
+			/* attach frontend */
+			memset(&si2168_config, 0, sizeof(si2168_config));
+			si2168_config.i2c_adapter = &adapter;
+			si2168_config.fe = &port->dvb.frontend;
+			si2168_config.ts_mode = SI2168_TS_SERIAL;
+			si2168_config.ts_clock_gapped = true;
+			memset(&info, 0, sizeof(struct i2c_board_info));
+			switch (port->nr) {
+			case 0:
+				info.addr = 0xc8 >> 1;
+				break;
+			case 1:
+				info.addr = 0xcc >> 1;
+				break;
+			}
+			strlcpy(info.type, "si2168", I2C_NAME_SIZE);
+			info.platform_data = &si2168_config;
+			request_module(info.type);
+			client_demod = i2c_new_device(&i2c_bus->i2c_adap,
+						      &info);
+			if (client_demod == NULL ||
+					client_demod->dev.driver == NULL)
+				break;
+			if (!try_module_get(client_demod->dev.driver->owner)) {
+				i2c_unregister_device(client_demod);
+				break;
+			}
+			port->i2c_client_demod = client_demod;
+
+			/* attach tuner */
+			memset(&si2157_config, 0, sizeof(si2157_config));
+			si2157_config.fe = port->dvb.frontend;
+			memset(&info, 0, sizeof(struct i2c_board_info));
+			strlcpy(info.type, "si2157", I2C_NAME_SIZE);
+			info.addr = 0xc0 >> 1;
+			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);
+				break;
+			}
+			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);
+				break;
+			}
+			port->i2c_client_tuner = client_tuner;
+			break;
+		}
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
 	case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
diff --git a/drivers/media/pci/saa7164/saa7164.h b/drivers/media/pci/saa7164/saa7164.h
index 37e450a..1b41849 100644
--- a/drivers/media/pci/saa7164/saa7164.h
+++ b/drivers/media/pci/saa7164/saa7164.h
@@ -83,6 +83,8 @@ 
 #define SAA7164_BOARD_HAUPPAUGE_HVR2250_3	8
 #define SAA7164_BOARD_HAUPPAUGE_HVR2200_4	9
 #define SAA7164_BOARD_HAUPPAUGE_HVR2200_5	10
+#define SAA7164_BOARD_HAUPPAUGE_HVR2205		11
+#define SAA7164_BOARD_HAUPPAUGE_HVR2215		12
 
 #define SAA7164_MAX_UNITS		8
 #define SAA7164_TS_NUMBER_OF_LINES	312