Re: cx23885: Add si2165 support for HVR-5500

2014-12-21 Thread Antti Palosaari

On 12/21/2014 09:23 PM, Matthias Schwarzott wrote:

On 20.12.2014 16:31, Antti Palosaari wrote:

Matthias and Mauro,

Hi Antti,
meanwhile HVR-4400 has been tested by multiple people. And it works
rather good for DVB-T.


My board has only satellite support, no terrestrial nor satellite. Even 
all those errors, it still creates frontend - and it even likely works, 
I didn't tested.


But as you likely saw from the messages, it prints any IO errors as 
registering terrestrial or cable frontend failed, because of missing 
chips. And module reference counts went wrong as unloading modules is 
impossible.




so you decided to add that patch, which makes rather big changes for
existing HVR-4400 models, without any testing. I plugged HVR-4400
version that has only DVB-S2 in my machine in order to start finding out
one lockdep issue but what I see is bad HVR-4400.


I checked that all known HVR-4400 and HVR-5500 versions have a
Si2161/Si2165 chip.

I checked your subsystem id 0070:c12a. In windows inf file it is listed
as "Hauppauge WinTV Starburst (Model 121x00, DVB-S2, IR)".
But this subsystem id is also part of the HVR-4400 entry (as is HVR-5500).

So I rechecked the HVR4400 entry.
It points to these subsys ids (plus description from inf file):
* 0070:c108 "Hauppauge WinTV HVR-4400 (Model 121xxx, Hybrid DVB-T/S2, IR)"
* 0070:c138 "Hauppauge WinTV HVR-5500 (Model 121xxx, Hybrid DVB-T/C/S2, IR)"
* 0070:c1f8 "Hauppauge WinTV HVR-5500 (Model 121xxx, Hybrid DVB-T/C/S2, IR)"
* 0070:c12a "Hauppauge WinTV Starburst (Model 121x00, DVB-S2, IR)"


My board is that Starburst. All those others, 4400 and 5500 models, are 
hybrid containing two receivers. Due to that, Starburst is only one 
which is broken.



I would also criticize Mauro as he has committed that patch. It should
be obvious for every experienced media developer that this kind of not
trivial change needs some more careful review or testing.

That patch should be done differently, not blindly trying to attach chip
drivers for non-existent chips. I think correct solution is to detect
different HW models somehow, probing or reading from eeprom or so. Then
make 2 profiles, one for boards having both satellite and
terristrial/cable and one for boards having satellite only.


As can be seen above it should be possible to decide by checking the
subsys id.
So having two board entries should be the best solution.
One for HVR-4400/HVR-5500 and the other for the Starburst.


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: cx23885: Add si2165 support for HVR-5500

2014-12-21 Thread Matthias Schwarzott
On 20.12.2014 16:31, Antti Palosaari wrote:
> Matthias and Mauro,
Hi Antti,
meanwhile HVR-4400 has been tested by multiple people. And it works
rather good for DVB-T.

> so you decided to add that patch, which makes rather big changes for
> existing HVR-4400 models, without any testing. I plugged HVR-4400
> version that has only DVB-S2 in my machine in order to start finding out
> one lockdep issue but what I see is bad HVR-4400.

I checked that all known HVR-4400 and HVR-5500 versions have a
Si2161/Si2165 chip.

I checked your subsystem id 0070:c12a. In windows inf file it is listed
as "Hauppauge WinTV Starburst (Model 121x00, DVB-S2, IR)".
But this subsystem id is also part of the HVR-4400 entry (as is HVR-5500).

So I rechecked the HVR4400 entry.
It points to these subsys ids (plus description from inf file):
* 0070:c108 "Hauppauge WinTV HVR-4400 (Model 121xxx, Hybrid DVB-T/S2, IR)"
* 0070:c138 "Hauppauge WinTV HVR-5500 (Model 121xxx, Hybrid DVB-T/C/S2, IR)"
* 0070:c1f8 "Hauppauge WinTV HVR-5500 (Model 121xxx, Hybrid DVB-T/C/S2, IR)"
* 0070:c12a "Hauppauge WinTV Starburst (Model 121x00, DVB-S2, IR)"

> 
> I would also criticize Mauro as he has committed that patch. It should
> be obvious for every experienced media developer that this kind of not
> trivial change needs some more careful review or testing.
> 
> That patch should be done differently, not blindly trying to attach chip
> drivers for non-existent chips. I think correct solution is to detect
> different HW models somehow, probing or reading from eeprom or so. Then
> make 2 profiles, one for boards having both satellite and
> terristrial/cable and one for boards having satellite only.
> 
As can be seen above it should be possible to decide by checking the
subsys id.
So having two board entries should be the best solution.
One for HVR-4400/HVR-5500 and the other for the Starburst.

Regards
Matthias


--
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


cx23885: Add si2165 support for HVR-5500

2014-12-20 Thread Antti Palosaari

Matthias and Mauro,
so you decided to add that patch, which makes rather big changes for 
existing HVR-4400 models, without any testing. I plugged HVR-4400 
version that has only DVB-S2 in my machine in order to start finding out 
one lockdep issue but what I see is bad HVR-4400.


*
commit 36efec48e2e6016e05364906720a0ec350a5d768
Author: Matthias Schwarzott 
Date:   Tue Jul 22 17:12:13 2014 -0300

[media] cx23885: Add si2165 support for HVR-5500

The same card entry is used for HVR-4400 and HVR-5500.
Only HVR-5500 has been tested.

Signed-off-by: Matthias Schwarzott 
Signed-off-by: Mauro Carvalho Chehab 

*

I would also criticize Mauro as he has committed that patch. It should 
be obvious for every experienced media developer that this kind of not 
trivial change needs some more careful review or testing.


That patch should be done differently, not blindly trying to attach chip 
drivers for non-existent chips. I think correct solution is to detect 
different HW models somehow, probing or reading from eeprom or so. Then 
make 2 profiles, one for boards having both satellite and 
terristrial/cable and one for boards having satellite only.



*

cx23885 driver version 0.0.4 loaded
CORE cx23885[0]: subsystem: 0070:c12a, board: Hauppauge WinTV-HVR4400 
[card=38,autodetected]

tveeprom 5-0050: Hauppauge model 121200, rev B2C3, serial# 4034388477
tveeprom 5-0050: MAC address is 00:0d:fe:77:e1:fd
tveeprom 5-0050: tuner model is Conexant CX24118A (idx 123, type 4)
tveeprom 5-0050: TV standards ATSC/DVB Digital (eeprom 0x80)
tveeprom 5-0050: audio processor is CX23888 (idx 40)
tveeprom 5-0050: decoder processor is CX23888 (idx 34)
tveeprom 5-0050: has no radio, has IR receiver, has no IR transmitter
cx23885[0]: warning: unknown hauppauge model #121200
cx23885[0]: hauppauge eeprom: model=121200
All bytes are equal. It is not a TEA5767
tuner 6-0060: Tuner -1 found with type(s) Radio TV.
tda18271 6-0060: creating new instance
Unknown device (0) detected @ 6-0060, device not supported.
tda18271_attach: [6-0060|M] error -22 on line 1285
tda18271 6-0060: destroying instance
tuner 6-0060: Tuner has no way to set tv freq
cx23885[0]: registered device video0 [v4l2]
cx23885[0]: registered device vbi0
cx23885[0]: registered ALSA audio device
cx23885_dvb_register() allocating 1 frontend(s)
cx23885[0]: cx23885 based dvb card
i2c i2c-5: a8293: Allegro A8293 SEC attached
DVB: registering new adapter (cx23885[0])
cx23885 :02:00.0: DVB: registering adapter 0 frontend 0 (NXP 
TDA10071)...

cx23885_dvb_register() allocating 1 frontend(s)
cx23885[0]: cx23885 based dvb card
cx23885[0]: frontend initialization failed
cx23885_dvb_register() dvb_register failed err = -22
cx23885_dev_setup() Failed to register dvb on VID_C
cx23885_dev_checkrevision() Hardware revision = 0xd0
cx23885[0]/0: found at :02:00.0, rev: 4, irq: 18, latency: 0, mmio: 
0xfe80


*

# ../rmmod.pl unload
Seeking media drivers at /lib/modules/3.18.0-rc4+/kernel/drivers/media/
found 0 modules
Seeking media drivers at /lib/modules/3.18.0-rc4+/extra/
found 511 modules
Seeking media drivers at /lib/modules/3.18.0-rc4+/updates/media/
found 511 modules
/sbin/rmmod cx23885
rmmod: ERROR: Module cx23885 is in use
/sbin/rmmod videobuf2_dvb
rmmod: ERROR: Module videobuf2_dvb is in use by: cx23885
/sbin/rmmod videobuf2_core
rmmod: ERROR: Module videobuf2_core is in use by: cx23885 videobuf2_dvb
/sbin/rmmod tuner
rmmod: ERROR: Module tuner is in use
/sbin/rmmod cx2341x
rmmod: ERROR: Module cx2341x is in use by: cx23885
/sbin/rmmod v4l2_common
rmmod: ERROR: Module v4l2_common is in use by: cx2341x cx23885 tuner 
videobuf2_core

/sbin/rmmod altera_ci
rmmod: ERROR: Module altera_ci is in use by: cx23885
/sbin/rmmod videobuf2_dma_sg
rmmod: ERROR: Module videobuf2_dma_sg is in use by: cx23885
/sbin/rmmod videodev
rmmod: ERROR: Module videodev is in use by: cx2341x cx23885 tuner 
v4l2_common videobuf2_core

/sbin/rmmod dvb_core
rmmod: ERROR: Module dvb_core is in use by: cx23885 altera_ci videobuf2_dvb
/sbin/rmmod a8293
rmmod: ERROR: Module a8293 is in use
/sbin/rmmod videobuf2_memops
rmmod: ERROR: Module videobuf2_memops is in use by: videobuf2_dma_sg
/sbin/rmmod tda18271
rmmod: ERROR: Module tda18271 is in use by: cx23885
/sbin/rmmod rc_core
rmmod: ERROR: Module rc_core is in use by: cx23885
/sbin/rmmod tveeprom
rmmod: ERROR: Module tveeprom is in use by: cx23885
/sbin/rmmod media
rmmod: ERROR: Module media is in use by: videodev
/sbin/rmmod tda10071
rmmod: ERROR: Module tda10071 is in use
/sbin/rmmod cx23885
rmmod: ERROR: Module cx23885 is in use
/sbin/rmmod videobuf2_dvb
rmmod: ERROR: Module videobuf2_dvb is in use by: cx23885
/sbin/rmmod videobuf2_core
rmmod: ERROR: Module videobuf2_core is in use by: cx23885 videobuf2_dvb
/sbin/rmmod tuner
rmmod: ERROR: Module tuner is in use
/sbin/rmmod cx2341x
rmmod: ERROR: Module cx2341x is in use by: cx23885
/sbin/rmmod v4l2_common

[PATCH 3/8] cx23885: Add si2165 support for HVR-5500

2014-07-22 Thread Matthias Schwarzott
The same card entry is used for HVR-4400 and HVR-5500.
Only HVR-5500 has been tested.

Signed-off-by: Matthias Schwarzott 
---
 drivers/media/pci/cx23885/Kconfig |  1 +
 drivers/media/pci/cx23885/cx23885-cards.c | 17 +---
 drivers/media/pci/cx23885/cx23885-dvb.c   | 43 +++
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx23885/Kconfig 
b/drivers/media/pci/cx23885/Kconfig
index d1dcb1d..6cd1db2 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -31,6 +31,7 @@ config VIDEO_CX23885
select DVB_TDA10071 if MEDIA_SUBDRV_AUTOSELECT
select DVB_A8293 if MEDIA_SUBDRV_AUTOSELECT
select DVB_MB86A20S if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SI2165 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
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 9723067..e63d447 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -619,7 +619,12 @@ struct cx23885_board cx23885_boards[] = {
},
[CX23885_BOARD_HAUPPAUGE_HVR4400] = {
.name   = "Hauppauge WinTV-HVR4400",
+   .porta  = CX23885_ANALOG_VIDEO,
.portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   .tuner_type = TUNER_NXP_TDA18271,
+   .tuner_addr = 0x60, /* 0xc0 >> 1 */
+   .tuner_bus  = 1,
},
[CX23885_BOARD_AVERMEDIA_HC81R] = {
.name   = "AVerTV Hybrid Express Slim HC81R",
@@ -1475,13 +1480,16 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
break;
case CX23885_BOARD_HAUPPAUGE_HVR4400:
/* GPIO-8 tda10071 demod reset */
+   /* GPIO-9 si2165 demod reset */
 
/* Put the parts into reset and back */
-   cx23885_gpio_enable(dev, GPIO_8, 1);
-   cx23885_gpio_clear(dev, GPIO_8);
+   cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
+
+   cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
mdelay(100);
-   cx23885_gpio_set(dev, GPIO_8);
+   cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
mdelay(100);
+
break;
case CX23885_BOARD_AVERMEDIA_HC81R:
cx_clear(MC417_CTL, 1);
@@ -1826,6 +1834,9 @@ void cx23885_card_setup(struct cx23885_dev *dev)
ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+   ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
+   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:
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index d037459..4822776 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include "tda10071.h"
 #include "a8293.h"
 #include "mb86a20s.h"
+#include "si2165.h"
 
 static unsigned int debug;
 
@@ -302,6 +303,11 @@ static struct tda18271_config 
hauppauge_hvr1210_tuner_config = {
.output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
+static struct tda18271_config hauppauge_hvr4400_tuner_config = {
+   .gate= TDA18271_GATE_DIGITAL,
+   .output_opt = TDA18271_OUTPUT_LT_OFF,
+};
+
 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
.atsc_6   = { .if_freq = 3250, .agc_mode = 3, .std = 4,
  .if_lvl = 1, .rfagc_top = 0x58 },
@@ -702,6 +708,12 @@ static const struct a8293_config hauppauge_a8293_config = {
.i2c_addr = 0x0b,
 };
 
+static const struct si2165_config hauppauge_hvr4400_si2165_config = {
+   .i2c_addr   = 0x64,
+   .chip_mode  = SI2165_MODE_PLL_XTAL,
+   .ref_freq_Hz= 1600,
+};
+
 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
 {
struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -1335,13 +1347,34 @@ static int dvb_register(struct cx23885_tsport *port)
break;
case CX23885_BOARD_HAUPPAUGE_HVR4400:
i2c_bus = &dev->i2c_bus[0];
-   fe0->dvb.frontend = dvb_attach(tda10071_attach,
+   i2c_bus2 = &dev->i2c_bus[1];
+   switch (port->nr) {
+   /* port b */
+   case 1:
+   fe0->dvb.frontend = dvb_attach(tda10071_attach,
 

[PATCH 4/4] cx23885: Add si2165 support for HVR-5500

2014-07-01 Thread Matthias Schwarzott
The same card entry is used for HVR-4400 and HVR-5500.
Only HVR-5500 has been tested.

Signed-off-by: Matthias Schwarzott 
---
 drivers/media/pci/cx23885/Kconfig |  1 +
 drivers/media/pci/cx23885/cx23885-cards.c | 17 +---
 drivers/media/pci/cx23885/cx23885-dvb.c   | 43 +++
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx23885/Kconfig 
b/drivers/media/pci/cx23885/Kconfig
index d1dcb1d..6cd1db2 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -31,6 +31,7 @@ config VIDEO_CX23885
select DVB_TDA10071 if MEDIA_SUBDRV_AUTOSELECT
select DVB_A8293 if MEDIA_SUBDRV_AUTOSELECT
select DVB_MB86A20S if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SI2165 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
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 79f20c8..6ed0551 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -619,7 +619,12 @@ struct cx23885_board cx23885_boards[] = {
},
[CX23885_BOARD_HAUPPAUGE_HVR4400] = {
.name   = "Hauppauge WinTV-HVR4400",
+   .porta  = CX23885_ANALOG_VIDEO,
.portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   .tuner_type = TUNER_NXP_TDA18271,
+   .tuner_addr = 0x60, /* 0xc0 >> 1 */
+   .tuner_bus  = 1,
},
[CX23885_BOARD_AVERMEDIA_HC81R] = {
.name   = "AVerTV Hybrid Express Slim HC81R",
@@ -1449,13 +1454,16 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
break;
case CX23885_BOARD_HAUPPAUGE_HVR4400:
/* GPIO-8 tda10071 demod reset */
+   /* GPIO-9 si2165 demod reset */
 
/* Put the parts into reset and back */
-   cx23885_gpio_enable(dev, GPIO_8, 1);
-   cx23885_gpio_clear(dev, GPIO_8);
+   cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
+
+   cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
mdelay(100);
-   cx23885_gpio_set(dev, GPIO_8);
+   cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
mdelay(100);
+
break;
case CX23885_BOARD_AVERMEDIA_HC81R:
cx_clear(MC417_CTL, 1);
@@ -1799,6 +1807,9 @@ void cx23885_card_setup(struct cx23885_dev *dev)
ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+   ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
+   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:
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index d037459..4822776 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include "tda10071.h"
 #include "a8293.h"
 #include "mb86a20s.h"
+#include "si2165.h"
 
 static unsigned int debug;
 
@@ -302,6 +303,11 @@ static struct tda18271_config 
hauppauge_hvr1210_tuner_config = {
.output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
+static struct tda18271_config hauppauge_hvr4400_tuner_config = {
+   .gate= TDA18271_GATE_DIGITAL,
+   .output_opt = TDA18271_OUTPUT_LT_OFF,
+};
+
 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
.atsc_6   = { .if_freq = 3250, .agc_mode = 3, .std = 4,
  .if_lvl = 1, .rfagc_top = 0x58 },
@@ -702,6 +708,12 @@ static const struct a8293_config hauppauge_a8293_config = {
.i2c_addr = 0x0b,
 };
 
+static const struct si2165_config hauppauge_hvr4400_si2165_config = {
+   .i2c_addr   = 0x64,
+   .chip_mode  = SI2165_MODE_PLL_XTAL,
+   .ref_freq_Hz= 1600,
+};
+
 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
 {
struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -1335,13 +1347,34 @@ static int dvb_register(struct cx23885_tsport *port)
break;
case CX23885_BOARD_HAUPPAUGE_HVR4400:
i2c_bus = &dev->i2c_bus[0];
-   fe0->dvb.frontend = dvb_attach(tda10071_attach,
+   i2c_bus2 = &dev->i2c_bus[1];
+   switch (port->nr) {
+   /* port b */
+   case 1:
+   fe0->dvb.frontend = dvb_attach(tda10071_attach,
 

[PATCH 3/3] cx23885: Add si2165 support for HVR-5500

2014-04-26 Thread Matthias Schwarzott
The same card entry is used for HVR-4400 and HVR-5500.
Only HVR-5500 has been tested.

Signed-off-by: Matthias Schwarzott 
---
 drivers/media/pci/cx23885/Kconfig |  1 +
 drivers/media/pci/cx23885/cx23885-cards.c | 17 +---
 drivers/media/pci/cx23885/cx23885-dvb.c   | 43 +++
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/cx23885/Kconfig 
b/drivers/media/pci/cx23885/Kconfig
index d1dcb1d..6cd1db2 100644
--- a/drivers/media/pci/cx23885/Kconfig
+++ b/drivers/media/pci/cx23885/Kconfig
@@ -31,6 +31,7 @@ config VIDEO_CX23885
select DVB_TDA10071 if MEDIA_SUBDRV_AUTOSELECT
select DVB_A8293 if MEDIA_SUBDRV_AUTOSELECT
select DVB_MB86A20S if MEDIA_SUBDRV_AUTOSELECT
+   select DVB_SI2165 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
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c 
b/drivers/media/pci/cx23885/cx23885-cards.c
index 79f20c8..6ed0551 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -619,7 +619,12 @@ struct cx23885_board cx23885_boards[] = {
},
[CX23885_BOARD_HAUPPAUGE_HVR4400] = {
.name   = "Hauppauge WinTV-HVR4400",
+   .porta  = CX23885_ANALOG_VIDEO,
.portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
+   .tuner_type = TUNER_NXP_TDA18271,
+   .tuner_addr = 0x60, /* 0xc0 >> 1 */
+   .tuner_bus  = 1,
},
[CX23885_BOARD_AVERMEDIA_HC81R] = {
.name   = "AVerTV Hybrid Express Slim HC81R",
@@ -1449,13 +1454,16 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
break;
case CX23885_BOARD_HAUPPAUGE_HVR4400:
/* GPIO-8 tda10071 demod reset */
+   /* GPIO-9 si2165 demod reset */
 
/* Put the parts into reset and back */
-   cx23885_gpio_enable(dev, GPIO_8, 1);
-   cx23885_gpio_clear(dev, GPIO_8);
+   cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
+
+   cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
mdelay(100);
-   cx23885_gpio_set(dev, GPIO_8);
+   cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
mdelay(100);
+
break;
case CX23885_BOARD_AVERMEDIA_HC81R:
cx_clear(MC417_CTL, 1);
@@ -1799,6 +1807,9 @@ void cx23885_card_setup(struct cx23885_dev *dev)
ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+   ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
+   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:
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c 
b/drivers/media/pci/cx23885/cx23885-dvb.c
index 4be01b3..ddb0e82 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
 #include "tda10071.h"
 #include "a8293.h"
 #include "mb86a20s.h"
+#include "si2165.h"
 
 static unsigned int debug;
 
@@ -302,6 +303,11 @@ static struct tda18271_config 
hauppauge_hvr1210_tuner_config = {
.output_opt = TDA18271_OUTPUT_LT_OFF,
 };
 
+static struct tda18271_config hauppauge_hvr4400_tuner_config = {
+   .gate= TDA18271_GATE_DIGITAL,
+   .output_opt = TDA18271_OUTPUT_LT_OFF,
+};
+
 static struct tda18271_std_map hauppauge_hvr127x_std_map = {
.atsc_6   = { .if_freq = 3250, .agc_mode = 3, .std = 4,
  .if_lvl = 1, .rfagc_top = 0x58 },
@@ -702,6 +708,12 @@ static const struct a8293_config hauppauge_a8293_config = {
.i2c_addr = 0x0b,
 };
 
+static const struct si2165_config hauppauge_hvr4400_si2165_config = {
+   .i2c_addr   = 0x64,
+   .chip_mode  = SI2165_MODE_PLL_XTAL,
+   .ref_freq_MHz   = 16,
+};
+
 static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
 {
struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -1331,13 +1343,34 @@ static int dvb_register(struct cx23885_tsport *port)
break;
case CX23885_BOARD_HAUPPAUGE_HVR4400:
i2c_bus = &dev->i2c_bus[0];
-   fe0->dvb.frontend = dvb_attach(tda10071_attach,
+   i2c_bus2 = &dev->i2c_bus[1];
+   switch (port->nr) {
+   /* port b */
+   case 1:
+   fe0->dvb.frontend = dvb_attach(tda10071_attach,