linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] tdfxfb: make use of DDC information about connected monitor
@ 2009-03-23 18:26 Krzysztof Helt
       [not found] ` <20090323192646.da98a636.krzysztof.h1-IjDXvh/HVVUAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Helt @ 2009-03-23 18:26 UTC (permalink / raw)
  To: Jean Delvare, Linux-fbdev-devel, linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Andrew Morton

From: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>

Read DDC information from a connected monitor
and use it to select initial mode (if the mode
is not specified).
Also, use the information to protect against
modes outside the monitor specs.

Signed-off-by: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>
---
 drivers/video/tdfxfb.c |   67 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index be40506..d48bcab 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -487,6 +487,12 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 		return -EINVAL;
 	}
 
+	if (info->monspecs.hfmax && info->monspecs.vfmax &&
+	    info->monspecs.dclkmax && fb_validate_mode(var, info) < 0) {
+		DPRINTK("mode outside monitor's specs\n");
+		return -EINVAL;
+	}
+
 	var->xres = (var->xres + 15) & ~15; /* could sometimes be 8 */
 	lpitch = var->xres * ((var->bits_per_pixel + 7) >> 3);
 
@@ -1355,6 +1361,23 @@ static void tdfxfb_delete_i2c_busses(struct tdfx_par *par)
 		i2c_del_adapter(&par->chan[1].adapter);
 	par->chan[1].par = NULL;
 }
+
+static int tdfxfb_probe_i2c_connector(struct tdfx_par *par,
+				      struct fb_monspecs *specs)
+{
+	u8 *edid = NULL;
+
+	DPRINTK("Probe DDC Bus\n");
+	if (par->chan[0].par)
+		edid = fb_ddc_read(&par->chan[0].adapter);
+
+	if (edid) {
+		fb_edid_to_monspecs(edid, specs);
+		kfree(edid);
+		return 0;
+	}
+	return 1;
+}
 #endif /* CONFIG_FB_3DFX_I2C */
 
 /**
@@ -1372,6 +1395,8 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
 	struct tdfx_par *default_par;
 	struct fb_info *info;
 	int err, lpitch;
+	struct fb_monspecs *specs;
+	bool found;
 
 	err = pci_enable_device(pdev);
 	if (err) {
@@ -1474,15 +1499,49 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev,
 	if (hwcursor)
 		info->fix.smem_len = (info->fix.smem_len - 1024) &
 					(PAGE_MASK << 1);
+	specs = &info->monspecs;
+	found = false;
+	info->var.bits_per_pixel = 8;
 #ifdef CONFIG_FB_3DFX_I2C
 	tdfxfb_create_i2c_busses(info);
+	err = tdfxfb_probe_i2c_connector(default_par, specs);
+
+	if (!err) {
+		if (specs->modedb == NULL)
+			DPRINTK("Unable to get Mode Database\n");
+		else {
+			const struct fb_videomode *m;
+
+			fb_videomode_to_modelist(specs->modedb,
+						 specs->modedb_len,
+						 &info->modelist);
+			m = fb_find_best_display(specs, &info->modelist);
+			if (m) {
+				fb_videomode_to_var(&info->var, m);
+				/* fill all other info->var's fields */
+				if (tdfxfb_check_var(&info->var, info) < 0)
+					info->var = tdfx_var;
+				else
+					found = true;
+			}
+		}
+	}
 #endif
-	if (!mode_option)
+	if (!mode_option && !found)
 		mode_option = "640x480@60";
 
-	err = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
-	if (!err || err == 4)
-		info->var = tdfx_var;
+	if (mode_option) {
+		err = fb_find_mode(&info->var, info, mode_option,
+				   specs->modedb, specs->modedb_len,
+				   NULL, info->var.bits_per_pixel);
+		if (!err || err == 4)
+			info->var = tdfx_var;
+	}
+
+	if (found) {
+		fb_destroy_modedb(specs->modedb);
+		specs->modedb = NULL;
+	}
 
 	/* maximize virtual vertical length */
 	lpitch = info->var.xres_virtual * ((info->var.bits_per_pixel + 7) >> 3);
-- 
1.5.2.2


----------------------------------------------------------------------
10% zysku na lokacie bankowej z gwarancja BFG. Sprawdz!
http://clk.tradedoubler.com/click?p=74281&a=1586724&g=17879004

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tdfxfb: make use of DDC information about connected monitor
       [not found] ` <20090323192646.da98a636.krzysztof.h1-IjDXvh/HVVUAvxtiuMwx3w@public.gmane.org>
@ 2009-03-24 21:35   ` Jean Delvare
  0 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2009-03-24 21:35 UTC (permalink / raw)
  To: Krzysztof Helt
  Cc: Linux-fbdev-devel, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Andrew Morton

Hi Krzysztof,

On Mon, 23 Mar 2009 19:26:46 +0100, Krzysztof Helt wrote:
> From: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>
> 
> Read DDC information from a connected monitor
> and use it to select initial mode (if the mode
> is not specified).
> Also, use the information to protect against
> modes outside the monitor specs.
> 
> Signed-off-by: Krzysztof Helt <krzysztof.h1-5tc4TXWwyLM@public.gmane.org>
> ---
>  drivers/video/tdfxfb.c |   67 +++++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 63 insertions(+), 4 deletions(-)

Patch tested successfully. Without the patch:

fb: 3Dfx Voodoo3 memory = 16384K
Console: switching to colour frame buffer device 80x30

With the patch:

fb: 3Dfx Voodoo3 memory = 16384K
Console: switching to colour frame buffer device 128x48

Much better! :) This is on a Voodoo3. If you want me to test something
in particular, just let me know.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tdfxfb: make use of DDC information about connected monitor
       [not found] ` <20090325063616.16A371D789D-PzGfQPfZplqOitzWlErfBcT2TbGLZofU@public.gmane.org>
@ 2009-03-25  8:06   ` Jean Delvare
       [not found]     ` <20090325090655.19fe3af2-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Delvare @ 2009-03-25  8:06 UTC (permalink / raw)
  Cc: Krzysztof Helt, Linux-fbdev-devel,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Andrew Morton

On 25 Mar 2009 07:36:15 +0100, krzysztof.h1-IjDXvh/HVVUAvxtiuMwx3w@public.gmane.org wrote:
> I have tested it on Voodoo3 3000 AGP and Voodoo5 AGP with LCD panel
> and CRT monitor. It is reallycool on CRT monitor - it returns
> a resolution with high refresh rate and quite useful
> (on my 15" CRT it is 800x600 at 85Hz).
> 
> If you can test the BT869 driver for a Voodoo3 card (mentioned
> in the i2c-voodoo3 doc) it would be great.

The bt869 driver was never ported to Linux 2.6, so no, I can't test it.
Not that I believe that the driver as it existed made much sense
anyway. It was more of an afternoon hack than anything else.
Controlling the video output using the BT869 should really be up to the
video driver (framebuffer or X) and not to the user.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tdfxfb: make use of DDC information about connected monitor
       [not found]     ` <20090325090655.19fe3af2-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2009-03-25 19:25       ` Krzysztof Helt
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Helt @ 2009-03-25 19:25 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Linux-fbdev-devel, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Andrew Morton

On Wed, 25 Mar 2009 09:06:55 +0100
Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:

> On 25 Mar 2009 07:36:15 +0100, krzysztof.h1-IjDXvh/HVVUAvxtiuMwx3w@public.gmane.org wrote:

> > If you can test the BT869 driver for a Voodoo3 card (mentioned
> > in the i2c-voodoo3 doc) it would be great.
> 
> The bt869 driver was never ported to Linux 2.6, so no, I can't test it.
> Not that I believe that the driver as it existed made much sense
> anyway. It was more of an afternoon hack than anything else.
> Controlling the video output using the BT869 should really be up to the
> video driver (framebuffer or X) and not to the user.
> 

I see. I found that there is something like bt869 driver in the lm-sensors
package but I didn't know details.

Thanks for answer,
Krzysztof


----------------------------------------------------------------------
Udar sloneczny prezesa Kaczynskiego... >>> http://link.interia.pl/f2083

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-25 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-23 18:26 [PATCH 2/2] tdfxfb: make use of DDC information about connected monitor Krzysztof Helt
     [not found] ` <20090323192646.da98a636.krzysztof.h1-IjDXvh/HVVUAvxtiuMwx3w@public.gmane.org>
2009-03-24 21:35   ` Jean Delvare
  -- strict thread matches above, loose matches on Subject: below --
2009-03-25  6:36 krzysztof.h1-IjDXvh/HVVUAvxtiuMwx3w
     [not found] ` <20090325063616.16A371D789D-PzGfQPfZplqOitzWlErfBcT2TbGLZofU@public.gmane.org>
2009-03-25  8:06   ` Jean Delvare
     [not found]     ` <20090325090655.19fe3af2-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-25 19:25       ` Krzysztof Helt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).