diff mbox

hdpvr: i2c fixups for fully functional IR support

Message ID 200909011019.35798.jarod@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Jarod Wilson Sept. 1, 2009, 2:19 p.m. UTC
Patch is against http://hg.jannau.net/hdpvr/

1) Adds support for building hdpvr i2c support when i2c is built as a
module (based on work by David Engel on the mythtv-users list)

2) Refines the hdpvr_i2c_write() success check (based on a thread in
the sagetv forums)

With this patch in place, and the latest lirc_zilog driver in my lirc
git tree, the IR part in my hdpvr works perfectly, both for reception
and transmitting.

Signed-off-by: Jarod Wilson <jarod@redhat.com>

---
 Makefile     |    4 +---
 hdpvr-core.c |    4 ++--
 hdpvr-i2c.c  |    5 ++++-
 3 files changed, 7 insertions(+), 6 deletions(-)

Comments

Andy Walls Sept. 2, 2009, 1:30 a.m. UTC | #1
On Tue, 2009-09-01 at 10:19 -0400, Jarod Wilson wrote:
> Patch is against http://hg.jannau.net/hdpvr/
> 
> 1) Adds support for building hdpvr i2c support when i2c is built as a
> module (based on work by David Engel on the mythtv-users list)
> 
> 2) Refines the hdpvr_i2c_write() success check (based on a thread in
> the sagetv forums)
> 
> With this patch in place, and the latest lirc_zilog driver in my lirc
> git tree, the IR part in my hdpvr works perfectly, both for reception
> and transmitting.
> 
> Signed-off-by: Jarod Wilson <jarod@redhat.com>

Jarod,

I recall a problem Brandon Jenkins had from last year, that when I2C was
enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
would produce a kernel oops.

Have you tested this on a machine with both an HVR-1600 and HD-PVR
installed?

Regards,
Andy


> ---
>  Makefile     |    4 +---
>  hdpvr-core.c |    4 ++--
>  hdpvr-i2c.c  |    5 ++++-
>  3 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff -r d49772394029 linux/drivers/media/video/hdpvr/Makefile
> --- a/linux/drivers/media/video/hdpvr/Makefile	Sun Apr 05 21:15:57 2009 +0200
> +++ b/linux/drivers/media/video/hdpvr/Makefile	Tue Sep 01 10:12:59 2009 -0400
> @@ -1,6 +1,4 @@
> -hdpvr-objs	:= hdpvr-control.o hdpvr-core.o hdpvr-video.o
> -
> -hdpvr-$(CONFIG_I2C) += hdpvr-i2c.o
> +hdpvr-objs	:= hdpvr-control.o hdpvr-core.o hdpvr-i2c.o hdpvr-video.o
>  
>  obj-$(CONFIG_VIDEO_HDPVR) += hdpvr.o
>  
> diff -r d49772394029 linux/drivers/media/video/hdpvr/hdpvr-core.c
> --- a/linux/drivers/media/video/hdpvr/hdpvr-core.c	Sun Apr 05 21:15:57 2009 +0200
> +++ b/linux/drivers/media/video/hdpvr/hdpvr-core.c	Tue Sep 01 10:12:59 2009 -0400
> @@ -362,7 +362,7 @@
>  		goto error;
>  	}
>  
> -#ifdef CONFIG_I2C
> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
>  	retval = hdpvr_register_i2c_adapter(dev);
>  	if (retval < 0) {
>  		v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n");
> @@ -413,7 +413,7 @@
>  	mutex_unlock(&dev->io_mutex);
>  
>  	/* deregister I2C adapter */
> -#ifdef CONFIG_I2C
> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
>  	mutex_lock(&dev->i2c_mutex);
>  	if (dev->i2c_adapter)
>  		i2c_del_adapter(dev->i2c_adapter);
> diff -r d49772394029 linux/drivers/media/video/hdpvr/hdpvr-i2c.c
> --- a/linux/drivers/media/video/hdpvr/hdpvr-i2c.c	Sun Apr 05 21:15:57 2009 +0200
> +++ b/linux/drivers/media/video/hdpvr/hdpvr-i2c.c	Tue Sep 01 10:12:59 2009 -0400
> @@ -10,6 +10,7 @@
>   *
>   */
>  
> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
>  #include <linux/i2c.h>
>  
>  #include "hdpvr.h"
> @@ -67,7 +68,7 @@
>  			      REQTYPE_I2C_WRITE_STAT, CTRL_READ_REQUEST,
>  			      0, 0, buf, 2, 1000);
>  
> -	if (ret == 2)
> +	if ((ret == 2) && (buf[1] == (len - 1)))
>  		ret = 0;
>  	else if (ret >= 0)
>  		ret = -EIO;
> @@ -164,3 +165,5 @@
>  error:
>  	return retval;
>  }
> +
> +#endif /* CONFIG_I2C */
> 

--
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
Jarod Wilson Sept. 2, 2009, 3:26 a.m. UTC | #2
On 09/01/2009 09:30 PM, Andy Walls wrote:
> On Tue, 2009-09-01 at 10:19 -0400, Jarod Wilson wrote:
>> Patch is against http://hg.jannau.net/hdpvr/
>>
>> 1) Adds support for building hdpvr i2c support when i2c is built as a
>> module (based on work by David Engel on the mythtv-users list)
>>
>> 2) Refines the hdpvr_i2c_write() success check (based on a thread in
>> the sagetv forums)
>>
>> With this patch in place, and the latest lirc_zilog driver in my lirc
>> git tree, the IR part in my hdpvr works perfectly, both for reception
>> and transmitting.
>>
>> Signed-off-by: Jarod Wilson<jarod@redhat.com>
>
> Jarod,
>
> I recall a problem Brandon Jenkins had from last year, that when I2C was
> enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
> would produce a kernel oops.
>
> Have you tested this on a machine with both an HVR-1600 and HD-PVR
> installed?

Hrm, no, haven't tested it with such a setup, don't have an HVR-1600. I 
do have an HVR-1250 that I think might suffice for testing though, if 
I'm thinking clearly.

Ugh. And I just noticed that while everything works swimmingly with a 
2.6.30 kernel base, the i2c changes in 2.6.31 actually break it, so 
there's gonna be at least one more patch coming... I'm an idjit for not 
testing w/2.6.31 before sending this in, I *knew* there were major i2c 
changes to account for... (Its actually the hdpvr driver oopsing, before 
one even tries loading lirc_zilog).
Jarod Wilson Sept. 3, 2009, 3:33 a.m. UTC | #3
On 09/01/2009 11:26 PM, Jarod Wilson wrote:
> On 09/01/2009 09:30 PM, Andy Walls wrote:
>> On Tue, 2009-09-01 at 10:19 -0400, Jarod Wilson wrote:
>>> Patch is against http://hg.jannau.net/hdpvr/
>>>
>>> 1) Adds support for building hdpvr i2c support when i2c is built as a
>>> module (based on work by David Engel on the mythtv-users list)
>>>
>>> 2) Refines the hdpvr_i2c_write() success check (based on a thread in
>>> the sagetv forums)
>>>
>>> With this patch in place, and the latest lirc_zilog driver in my lirc
>>> git tree, the IR part in my hdpvr works perfectly, both for reception
>>> and transmitting.
>>>
>>> Signed-off-by: Jarod Wilson<jarod@redhat.com>
>>
>> Jarod,
>>
>> I recall a problem Brandon Jenkins had from last year, that when I2C was
>> enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
>> would produce a kernel oops.
>>
>> Have you tested this on a machine with both an HVR-1600 and HD-PVR
>> installed?
>
> Hrm, no, haven't tested it with such a setup, don't have an HVR-1600. I
> do have an HVR-1250 that I think might suffice for testing though, if
> I'm thinking clearly.

Hrm. A brief google search suggests the 1250 IR part isn't enabled. I 
see a number of i2c devices in i2cdetect -l output, but none that say 
anything about IR... I could just plug the hdpvr in there and see what 
happens, I suppose...

> Ugh. And I just noticed that while everything works swimmingly with a
> 2.6.30 kernel base, the i2c changes in 2.6.31 actually break it, so
> there's gonna be at least one more patch coming... I'm an idjit for not
> testing w/2.6.31 before sending this in, I *knew* there were major i2c
> changes to account for... (Its actually the hdpvr driver oopsing, before
> one even tries loading lirc_zilog).

Getting closer. The hdpvr driver is no longer oopsing, and lirc_zilog 
binds correctly. Transmit and receive are working too, but there's still 
an oops on module unload I'm tracking down. Should be able to finish 
sorting it all out tomorrow and get patches into the mail.
Andy Walls Sept. 3, 2009, 11:50 a.m. UTC | #4
On Wed, 2009-09-02 at 23:33 -0400, Jarod Wilson wrote:
> On 09/01/2009 11:26 PM, Jarod Wilson wrote:
> > On 09/01/2009 09:30 PM, Andy Walls wrote:
> >> On Tue, 2009-09-01 at 10:19 -0400, Jarod Wilson wrote:
> >>> Patch is against http://hg.jannau.net/hdpvr/
> >>>
> >>> 1) Adds support for building hdpvr i2c support when i2c is built as a
> >>> module (based on work by David Engel on the mythtv-users list)
> >>>
> >>> 2) Refines the hdpvr_i2c_write() success check (based on a thread in
> >>> the sagetv forums)
> >>>
> >>> With this patch in place, and the latest lirc_zilog driver in my lirc
> >>> git tree, the IR part in my hdpvr works perfectly, both for reception
> >>> and transmitting.
> >>>
> >>> Signed-off-by: Jarod Wilson<jarod@redhat.com>
> >>
> >> Jarod,
> >>
> >> I recall a problem Brandon Jenkins had from last year, that when I2C was
> >> enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
> >> would produce a kernel oops.
> >>
> >> Have you tested this on a machine with both an HVR-1600 and HD-PVR
> >> installed?
> >
> > Hrm, no, haven't tested it with such a setup, don't have an HVR-1600. I
> > do have an HVR-1250 that I think might suffice for testing though, if
> > I'm thinking clearly.
> 
> Hrm. A brief google search suggests the 1250 IR part isn't enabled. I 
> see a number of i2c devices in i2cdetect -l output, but none that say 
> anything about IR... I could just plug the hdpvr in there and see what 
> happens, I suppose...

You should try that.  It was an issue of legacy I2C driver probing that
caused the hdpvr module to have problems.  The cx18 driver simply
stimulated the i2c subsystem to do legacy probing (via the tuner modules
IIRC)?  See the email I sent you.


> > Ugh. And I just noticed that while everything works swimmingly with a
> > 2.6.30 kernel base, the i2c changes in 2.6.31 actually break it, so
> > there's gonna be at least one more patch coming... I'm an idjit for not
> > testing w/2.6.31 before sending this in, I *knew* there were major i2c
> > changes to account for... (Its actually the hdpvr driver oopsing, before
> > one even tries loading lirc_zilog).
> 
> Getting closer. The hdpvr driver is no longer oopsing, and lirc_zilog 
> binds correctly. Transmit and receive are working too, but there's still 
> an oops on module unload I'm tracking down. Should be able to finish 
> sorting it all out tomorrow and get patches into the mail.


Regards,
Andy

--
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
Jarod Wilson Sept. 3, 2009, 8:02 p.m. UTC | #5
On Sep 3, 2009, at 7:50 AM, Andy Walls wrote:

>>>> I recall a problem Brandon Jenkins had from last year, that when  
>>>> I2C was
>>>> enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
>>>> would produce a kernel oops.
>>>>
>>>> Have you tested this on a machine with both an HVR-1600 and HD-PVR
>>>> installed?
>>>
>>> Hrm, no, haven't tested it with such a setup, don't have an  
>>> HVR-1600. I
>>> do have an HVR-1250 that I think might suffice for testing though,  
>>> if
>>> I'm thinking clearly.
>>
>> Hrm. A brief google search suggests the 1250 IR part isn't enabled. I
>> see a number of i2c devices in i2cdetect -l output, but none that say
>> anything about IR... I could just plug the hdpvr in there and see  
>> what
>> happens, I suppose...
>
> You should try that.  It was an issue of legacy I2C driver probing  
> that
> caused the hdpvr module to have problems.  The cx18 driver simply
> stimulated the i2c subsystem to do legacy probing (via the tuner  
> modules
> IIRC)?  See the email I sent you.

So from what I can tell, the i2c changes in 2.6.31 *should* prevent  
that from happening, and now that I've got everything working on  
2.6.31 too, I'll try hooking up my hdpvr to my box w/an hvr-1250,  
hvr-1800 and pchdtv hd-3000 in it and see what blows up (hopefully  
nothing...).
Janne Grunau Sept. 3, 2009, 9:32 p.m. UTC | #6
On Thu, Sep 03, 2009 at 04:02:12PM -0400, Jarod Wilson wrote:
> On Sep 3, 2009, at 7:50 AM, Andy Walls wrote:
> 
> >> Hrm. A brief google search suggests the 1250 IR part isn't enabled. I
> >> see a number of i2c devices in i2cdetect -l output, but none that say
> >> anything about IR... I could just plug the hdpvr in there and see  
> >> what
> >> happens, I suppose...
> >
> > You should try that.  It was an issue of legacy I2C driver probing  
> > that
> > caused the hdpvr module to have problems.  The cx18 driver simply
> > stimulated the i2c subsystem to do legacy probing (via the tuner  
> > modules
> > IIRC)?  See the email I sent you.
> 
> So from what I can tell, the i2c changes in 2.6.31 *should* prevent  
> that from happening, and now that I've got everything working on  
> 2.6.31 too, I'll try hooking up my hdpvr to my box w/an hvr-1250,  
> hvr-1800 and pchdtv hd-3000 in it and see what blows up (hopefully  
> nothing...).

We still need something to prevent it from happening with older kernels.
Easiest solution would be to disable it for 2.6.30 and earlier.

Janne
--
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
Jarod Wilson Sept. 4, 2009, 5:05 a.m. UTC | #7
On 09/03/2009 05:32 PM, Janne Grunau wrote:
> On Thu, Sep 03, 2009 at 04:02:12PM -0400, Jarod Wilson wrote:
>> On Sep 3, 2009, at 7:50 AM, Andy Walls wrote:
>>
>>>> Hrm. A brief google search suggests the 1250 IR part isn't enabled. I
>>>> see a number of i2c devices in i2cdetect -l output, but none that say
>>>> anything about IR... I could just plug the hdpvr in there and see
>>>> what
>>>> happens, I suppose...
>>>
>>> You should try that.  It was an issue of legacy I2C driver probing
>>> that
>>> caused the hdpvr module to have problems.  The cx18 driver simply
>>> stimulated the i2c subsystem to do legacy probing (via the tuner
>>> modules
>>> IIRC)?  See the email I sent you.
>>
>> So from what I can tell, the i2c changes in 2.6.31 *should* prevent
>> that from happening, and now that I've got everything working on
>> 2.6.31 too, I'll try hooking up my hdpvr to my box w/an hvr-1250,
>> hvr-1800 and pchdtv hd-3000 in it and see what blows up (hopefully
>> nothing...).
>
> We still need something to prevent it from happening with older kernels.
> Easiest solution would be to disable it for 2.6.30 and earlier.

So I just tried a few permutations of hooking it up to the previously 
mentioned box, running a 2.6.29.6 kernel. No oops hooking the hdpvr up 
after everything else is already up, and no problems booting the system 
w/the hdpvr already connected (in which case it was the first device set 
up). One i2c adapter exposed by the hd-3000, three each by the hvr-1800 
and the hvr-1250, and the one on the hdpvr.

So perhaps we're okay, but I couldn't say for certain if its okay in 
combination with the hvr-1600 (i.e. Brandon's setup). Maybe skip 
enabling the i2c bits by default on kernels prior to 2.6.31, but add a 
modparam to let people enable them if they want to try it out?
Brandon Jenkins Sept. 13, 2009, 5:23 p.m. UTC | #8
On Tue, Sep 1, 2009 at 9:30 PM, Andy Walls <awalls@radix.net> wrote:
> On Tue, 2009-09-01 at 10:19 -0400, Jarod Wilson wrote:
>> Patch is against http://hg.jannau.net/hdpvr/
>>
>> 1) Adds support for building hdpvr i2c support when i2c is built as a
>> module (based on work by David Engel on the mythtv-users list)
>>
>> 2) Refines the hdpvr_i2c_write() success check (based on a thread in
>> the sagetv forums)
>>
>> With this patch in place, and the latest lirc_zilog driver in my lirc
>> git tree, the IR part in my hdpvr works perfectly, both for reception
>> and transmitting.
>>
>> Signed-off-by: Jarod Wilson <jarod@redhat.com>
>
> Jarod,
>
> I recall a problem Brandon Jenkins had from last year, that when I2C was
> enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
> would produce a kernel oops.
>
> Have you tested this on a machine with both an HVR-1600 and HD-PVR
> installed?
>
> Regards,
> Andy
>
>

I don't mind testing. Currently I am running ArchLinux 64-bit,
kernel26-2.6.30.6-1. Please tell me where to build the driver from.

Thanks,

Brandon
--
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
Jarod Wilson Sept. 13, 2009, 9:04 p.m. UTC | #9
On Sep 13, 2009, at 1:23 PM, Brandon Jenkins wrote:

> On Tue, Sep 1, 2009 at 9:30 PM, Andy Walls <awalls@radix.net> wrote:
>> On Tue, 2009-09-01 at 10:19 -0400, Jarod Wilson wrote:
>>> Patch is against http://hg.jannau.net/hdpvr/
>>>
>>> 1) Adds support for building hdpvr i2c support when i2c is built  
>>> as a
>>> module (based on work by David Engel on the mythtv-users list)
>>>
>>> 2) Refines the hdpvr_i2c_write() success check (based on a thread in
>>> the sagetv forums)
>>>
>>> With this patch in place, and the latest lirc_zilog driver in my  
>>> lirc
>>> git tree, the IR part in my hdpvr works perfectly, both for  
>>> reception
>>> and transmitting.
>>>
>>> Signed-off-by: Jarod Wilson <jarod@redhat.com>
>>
>> Jarod,
>>
>> I recall a problem Brandon Jenkins had from last year, that when  
>> I2C was
>> enabled in hdpvr, his machine with multiple HVR-1600s and an HD-PVR
>> would produce a kernel oops.
>>
>> Have you tested this on a machine with both an HVR-1600 and HD-PVR
>> installed?
>>
>> Regards,
>> Andy
>>
>>
>
> I don't mind testing. Currently I am running ArchLinux 64-bit,
> kernel26-2.6.30.6-1. Please tell me where to build the driver from.


Hrm... It *was* in Janne's hdpvr tree, but it seems to have gone  
missing... v4l-dvb tip + this patch should work too:

http://wilsonet.com/jarod/junk/hdpvr-ir/hdpvr-ir-2.6.31.patch

This is exactly what I put in the Fedora 2.6.31 kernel, iirc, and  
works a treat here. Have also tested against 2.6.29 in a box with a  
pcHDTV HD-3000 a Hauppauge HVR-1250 and HVR-1800 in it with no issues,  
so fingers crossed...
Janne Grunau Sept. 13, 2009, 10:13 p.m. UTC | #10
On Sun, Sep 13, 2009 at 05:04:16PM -0400, Jarod Wilson wrote:
> On Sep 13, 2009, at 1:23 PM, Brandon Jenkins wrote:
> 
> > I don't mind testing. Currently I am running ArchLinux 64-bit,
> > kernel26-2.6.30.6-1. Please tell me where to build the driver from.
> 
> Hrm... It *was* in Janne's hdpvr tree, but it seems to have gone  
> missing...

It's in http://hg.jannau.net/hdpvr. I just merged several weeks of
v4l-dvb changes after the last commit. So it's not at the top of the
log.

Janne
--
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
Jarod Wilson Sept. 14, 2009, 1:06 a.m. UTC | #11
On 09/13/2009 06:13 PM, Janne Grunau wrote:
> On Sun, Sep 13, 2009 at 05:04:16PM -0400, Jarod Wilson wrote:
>> On Sep 13, 2009, at 1:23 PM, Brandon Jenkins wrote:
>>
>>> I don't mind testing. Currently I am running ArchLinux 64-bit,
>>> kernel26-2.6.30.6-1. Please tell me where to build the driver from.
>>
>> Hrm... It *was* in Janne's hdpvr tree, but it seems to have gone
>> missing...
>
> It's in http://hg.jannau.net/hdpvr. I just merged several weeks of
> v4l-dvb changes after the last commit. So it's not at the top of the
> log.

Bah, so it is. I looked at the actual source files and somehow thought I 
didn't see the latest bits in there, but I just looked again, and you're 
of course right, everything's there...
Brandon Jenkins Sept. 14, 2009, 1:32 p.m. UTC | #12
Driver build procedure used:

Cloned http://hg.jannau.net/hdpvr
Pulled http://linuxtv.org/hg/v4l-dvb/
Pulled http://linuxtv.org/hg/~awalls/v4l-dvb/

This should bring in all changes for HDPVR and CX18.

What specifically would you like me to test? I can't reload the
modules until the kids are done watching TV. :)

Thanks,

Brandon
--
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
Jarod Wilson Sept. 14, 2009, 2:34 p.m. UTC | #13
On 09/14/2009 09:32 AM, Brandon Jenkins wrote:
> Driver build procedure used:
>
> Cloned http://hg.jannau.net/hdpvr
> Pulled http://linuxtv.org/hg/v4l-dvb/
> Pulled http://linuxtv.org/hg/~awalls/v4l-dvb/
>
> This should bring in all changes for HDPVR and CX18.
>
> What specifically would you like me to test? I can't reload the
> modules until the kids are done watching TV. :)

Whatever it was you did last time that was triggering an oops... Things 
I did myself were hotplugging the hdpvr after everything else was 
already up, and booting with the hdpvr connected (which in my case, led 
to it being set up before any of the other cards).
diff mbox

Patch

diff -r d49772394029 linux/drivers/media/video/hdpvr/Makefile
--- a/linux/drivers/media/video/hdpvr/Makefile	Sun Apr 05 21:15:57 2009 +0200
+++ b/linux/drivers/media/video/hdpvr/Makefile	Tue Sep 01 10:12:59 2009 -0400
@@ -1,6 +1,4 @@ 
-hdpvr-objs	:= hdpvr-control.o hdpvr-core.o hdpvr-video.o
-
-hdpvr-$(CONFIG_I2C) += hdpvr-i2c.o
+hdpvr-objs	:= hdpvr-control.o hdpvr-core.o hdpvr-i2c.o hdpvr-video.o
 
 obj-$(CONFIG_VIDEO_HDPVR) += hdpvr.o
 
diff -r d49772394029 linux/drivers/media/video/hdpvr/hdpvr-core.c
--- a/linux/drivers/media/video/hdpvr/hdpvr-core.c	Sun Apr 05 21:15:57 2009 +0200
+++ b/linux/drivers/media/video/hdpvr/hdpvr-core.c	Tue Sep 01 10:12:59 2009 -0400
@@ -362,7 +362,7 @@ 
 		goto error;
 	}
 
-#ifdef CONFIG_I2C
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	retval = hdpvr_register_i2c_adapter(dev);
 	if (retval < 0) {
 		v4l2_err(&dev->v4l2_dev, "registering i2c adapter failed\n");
@@ -413,7 +413,7 @@ 
 	mutex_unlock(&dev->io_mutex);
 
 	/* deregister I2C adapter */
-#ifdef CONFIG_I2C
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	mutex_lock(&dev->i2c_mutex);
 	if (dev->i2c_adapter)
 		i2c_del_adapter(dev->i2c_adapter);
diff -r d49772394029 linux/drivers/media/video/hdpvr/hdpvr-i2c.c
--- a/linux/drivers/media/video/hdpvr/hdpvr-i2c.c	Sun Apr 05 21:15:57 2009 +0200
+++ b/linux/drivers/media/video/hdpvr/hdpvr-i2c.c	Tue Sep 01 10:12:59 2009 -0400
@@ -10,6 +10,7 @@ 
  *
  */
 
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 #include <linux/i2c.h>
 
 #include "hdpvr.h"
@@ -67,7 +68,7 @@ 
 			      REQTYPE_I2C_WRITE_STAT, CTRL_READ_REQUEST,
 			      0, 0, buf, 2, 1000);
 
-	if (ret == 2)
+	if ((ret == 2) && (buf[1] == (len - 1)))
 		ret = 0;
 	else if (ret >= 0)
 		ret = -EIO;
@@ -164,3 +165,5 @@ 
 error:
 	return retval;
 }
+
+#endif /* CONFIG_I2C */