Skip to contentSkip to conversation

Rivafb I2C problem, new patch

PATCH Andrew Morton 4 participants 8 messages Jul 12, 2004 – Jul 13, 2004 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

Maybe Greg, or the linux-fbdev-devel denizens can comment upon this?

Begin forwarded message:

Date: Tue, 13 Jul 2004 01:24:02 +0200
From: Nicolas Boichat <[email protected]>
To: [email protected]
Subject: Rivafb I2C problem, new patch

Hello,

I'm currently writing a DDC/CI tool for Linux (DDC/CI is the protocol which permits to modify monitor parameters without using the OSD), see http://www.boichat.ch/nicolas/ddcci .

I use the new rivafb I2C support, but a problem appeared: the I2C bus is immediately deleted after the DDC2 EDID is read, but I need to access it from my application!

I attached a patch which fixes this problem: the bus is deleted only when the driver is unloaded (please note that the atyfb behave like my patched version). Could you add it to the next -mm kernel release ?

I also contacted the driver maintainer but he seems not to answer (I sent an e-mail to him about a week ago).

Best regards,

Nicolas Boichat

drivers/video/riva/fbdev.c renamed from drivers/video/riva.old/fbdev.c +8 -3
@@ -1773,7 +1773,7 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	int i;
 
-	riva_create_i2c_busses(par);
+	//riva_create_i2c_busses(par);
 	for (i = par->bus; i >= 1; i--) {
 		riva_probe_i2c_connector(par, i, &par->EDID);
 		if (par->EDID) {
@@ -1781,7 +1781,7 @@
 			break;
 		}
 	}
-	riva_delete_i2c_busses(par);
+	//riva_delete_i2c_busses(par);
 #endif
 #endif
 }
@@ -1933,6 +1933,8 @@
 	}
 #endif /* CONFIG_MTRR */
 
+	riva_create_i2c_busses((struct riva_par *) info->par);
+
 	info->fbops = &riva_fb_ops;
 	info->fix = rivafb_fix;
 	riva_get_EDID(info, pd);
@@ -1961,6 +1963,7 @@
 	return 0;
 
 err_out_iounmap_fb:
+	riva_delete_i2c_busses((struct riva_par *) info->par);
 	iounmap(info->screen_base);
 err_out_free_base1:
 	if (default_par->riva.Architecture == NV_ARCH_03) 
@@ -1985,10 +1988,12 @@
 {
 	struct fb_info *info = pci_get_drvdata(pd);
 	struct riva_par *par = (struct riva_par *) info->par;
-	
+
 	if (!info)
 		return;
 
+	riva_delete_i2c_busses(par);
+
 	unregister_framebuffer(info);
 #ifdef CONFIG_MTRR
 	if (par->mtrr.vram_valid)
#1 lore raw
Quoted 19 lines · Andrew Morton

Maybe Greg, or the linux-fbdev-devel denizens can comment upon this?

Begin forwarded message:

Date: Tue, 13 Jul 2004 01:24:02 +0200
From: Nicolas Boichat <[email protected]>
To: [email protected]
Subject: Rivafb I2C problem, new patch

Hello,

I'm currently writing a DDC/CI tool for Linux (DDC/CI is the protocol which permits to modify monitor parameters without using the OSD), see
http://www.boichat.ch/nicolas/ddcci .

Quoted 7 lines

I use the new rivafb I2C support, but a problem appeared: the I2C bus is immediately deleted after the DDC2 EDID is read, but I need to access it from my application!

I attached a patch which fixes this problem: the bus is deleted only when the driver is unloaded (please note that the atyfb behave like my patched version). Could you add it to the next -mm kernel release ?

Well, you shouldn't comment out those calls, just delete them.

Other than that, from an i2c standpoint, the patch looks sane, but I would check with the maintainer, as there might be some reason they delete the bus right after using it.

thanks,

greg k-h

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#2 lore raw
In reply to Andrew Morton
Quoted 22 lines · Andrew Morton

Maybe Greg, or the linux-fbdev-devel denizens can comment upon this?

Begin forwarded message:

Date: Tue, 13 Jul 2004 01:24:02 +0200
From: Nicolas Boichat <[email protected]>
To: [email protected]
Subject: Rivafb I2C problem, new patch

Hello,

I'm currently writing a DDC/CI tool for Linux (DDC/CI is the protocol which permits to modify monitor parameters without using the OSD), see
http://www.boichat.ch/nicolas/ddcci .

I use the new rivafb I2C support, but a problem appeared: the I2C bus is immediately deleted after the DDC2 EDID is read, but I need to access it from my application!

Quoted 6 lines

I attached a patch which fixes this problem: the bus is deleted only when the driver is unloaded (please note that the atyfb behave like my patched version). Could you add it to the next -mm kernel release ?

I also contacted the driver maintainer but he seems not to answer (I sent an e-mail to him about a week ago).

I'm not the maintainer of rivafb but I added the DDC2 support for it. The bus was destroyed because there was no use for it after reading the EDID block, and fbdev has no interface (yet) to re-read it again.

It doesn't matter to me whether the bus is immediately deleted or not, so the patch is fine by me.

Tony

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#3 lore raw

Hello,

Thanks for your answers.

I attached a new patch: I deleted the lines that were commented out.

Best regards,

Nicolas

Quoted 8 lines · Antonino A. Daplas

I'm not the maintainer of rivafb but I added the DDC2 support for it. The bus was destroyed because there was no use for it after reading the EDID block, and fbdev has no interface (yet) to re-read it again.

It doesn't matter to me whether the bus is immediately deleted or not, so the patch is fine by me.

Tony

Quoted 9 lines · Greg KH

Well, you shouldn't comment out those calls, just delete them.

Other than that, from an i2c standpoint, the patch looks sane, but I would check with the maintainer, as there might be some reason they delete the bus right after using it.

thanks,

greg k-h

drivers/video/riva/fbdev.c renamed from drivers/video/riva/fbdev.c.old +5 -2
@@ -1773,7 +1773,6 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	int i;
 
-	riva_create_i2c_busses(par);
 	for (i = par->bus; i >= 1; i--) {
 		riva_probe_i2c_connector(par, i, &par->EDID);
 		if (par->EDID) {
@@ -1781,7 +1780,6 @@
 			break;
 		}
 	}
-	riva_delete_i2c_busses(par);
 #endif
 #endif
 }
@@ -1933,6 +1931,8 @@
 	}
 #endif /* CONFIG_MTRR */
 
+	riva_create_i2c_busses((struct riva_par *) info->par);
+
 	info->fbops = &riva_fb_ops;
 	info->fix = rivafb_fix;
 	riva_get_EDID(info, pd);
@@ -1961,6 +1961,7 @@
 	return 0;
 
 err_out_iounmap_fb:
+	riva_delete_i2c_busses((struct riva_par *) info->par);
 	iounmap(info->screen_base);
 err_out_free_base1:
 	if (default_par->riva.Architecture == NV_ARCH_03) 
@@ -1989,6 +1990,8 @@
 	if (!info)
 		return;
 
+	riva_delete_i2c_busses(par);
+
 	unregister_framebuffer(info);
 #ifdef CONFIG_MTRR
 	if (par->mtrr.vram_valid)
#4 lore raw
Quoted 6 lines · Nicolas Boichat

Hello,

Thanks for your answers.

I attached a new patch: I deleted the lines that were commented out.

One thing I forgot, make sure it compiles when CONFIG_FB_RIVA_I2C is set or not.

Tony

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#5 lore raw

Hello,

Good idea... it didn't compile. Fixed patch attached.

Best regards,

Nicolas

Quoted 5 lines · Antonino A. Daplas
Quoted 4 lines · Nicolas Boichat

Hello,

Thanks for your answers.

Quoted 10 lines
Quoted 2 lines

I attached a new patch: I deleted the lines that were commented out.

One thing I forgot, make sure it compiles when CONFIG_FB_RIVA_I2C is set or not.

Tony

fbdev.c renamed from fbdev.c.old +11 -2
@@ -1773,7 +1773,6 @@
 	struct riva_par *par = (struct riva_par *) info->par;
 	int i;
 
-	riva_create_i2c_busses(par);
 	for (i = par->bus; i >= 1; i--) {
 		riva_probe_i2c_connector(par, i, &par->EDID);
 		if (par->EDID) {
@@ -1781,7 +1780,6 @@
 			break;
 		}
 	}
-	riva_delete_i2c_busses(par);
 #endif
 #endif
 }
@@ -1933,6 +1931,10 @@
 	}
 #endif /* CONFIG_MTRR */
 
+#ifdef CONFIG_FB_RIVA_I2C
+	riva_create_i2c_busses((struct riva_par *) info->par);
+#endif
+
 	info->fbops = &riva_fb_ops;
 	info->fix = rivafb_fix;
 	riva_get_EDID(info, pd);
@@ -1961,6 +1963,9 @@
 	return 0;
 
 err_out_iounmap_fb:
+#ifdef CONFIG_FB_RIVA_I2C
+	riva_delete_i2c_busses((struct riva_par *) info->par);
+#endif
 	iounmap(info->screen_base);
 err_out_free_base1:
 	if (default_par->riva.Architecture == NV_ARCH_03) 
@@ -1989,6 +1994,10 @@
 	if (!info)
 		return;
 
+#ifdef CONFIG_FB_RIVA_I2C
+	riva_delete_i2c_busses(par);
+#endif
+
 	unregister_framebuffer(info);
 #ifdef CONFIG_MTRR
 	if (par->mtrr.vram_valid)
#6 lore raw
Quoted 2 lines · Nicolas Boichat

Good idea... it didn't compile. Fixed patch attached.

Please send a complete new patch, with a changelog.

Thanks.

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com

#7 lore raw

Hello,

This should be the last patch, the changelog is at the beginning of the file.

Best regards,

Nicolas

Quoted 8 lines · Andrew Morton
Quoted 2 lines · Nicolas Boichat

Good idea... it didn't compile. Fixed patch attached.

Please send a complete new patch, with a changelog.

Thanks.

From: Nicolas Boichat <[email protected]>

The I2C busses opened by rivafb were deleted immediately after reading the EDID, but they should be kept open, so user-space applications can use them.

They are now deleted when the driver is unloaded.

---

 linux/drivers/video/riva/fbdev.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
drivers/video/riva/fbdev.c renamed from drivers/video/riva/fbdev.c.old +11 -2
diff -puN linux/drivers/video/riva/fbdev.c.old  linux/drivers/video/riva/fbdev.c
@@ -1773,7 +1773,6 @@ static void riva_get_EDID(struct fb_info
 	struct riva_par *par = (struct riva_par *) info->par;
 	int i;
 
-	riva_create_i2c_busses(par);
 	for (i = par->bus; i >= 1; i--) {
 		riva_probe_i2c_connector(par, i, &par->EDID);
 		if (par->EDID) {
@@ -1781,7 +1780,6 @@ static void riva_get_EDID(struct fb_info
 			break;
 		}
 	}
-	riva_delete_i2c_busses(par);
 #endif
 #endif
 }
@@ -1933,6 +1931,10 @@ static int __devinit rivafb_probe(struct
 	}
 #endif /* CONFIG_MTRR */
 
+#ifdef CONFIG_FB_RIVA_I2C
+	riva_create_i2c_busses((struct riva_par *) info->par);
+#endif
+
 	info->fbops = &riva_fb_ops;
 	info->fix = rivafb_fix;
 	riva_get_EDID(info, pd);
@@ -1961,6 +1963,9 @@ static int __devinit rivafb_probe(struct
 	return 0;
 
 err_out_iounmap_fb:
+#ifdef CONFIG_FB_RIVA_I2C
+	riva_delete_i2c_busses((struct riva_par *) info->par);
+#endif
 	iounmap(info->screen_base);
 err_out_free_base1:
 	if (default_par->riva.Architecture == NV_ARCH_03) 
@@ -1989,6 +1994,10 @@ static void __exit rivafb_remove(struct 
 	if (!info)
 		return;
 
+#ifdef CONFIG_FB_RIVA_I2C
+	riva_delete_i2c_busses(par);
+#endif
+
 	unregister_framebuffer(info);
 #ifdef CONFIG_MTRR
 	if (par->mtrr.vram_valid)