linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 18/33] pm3fb: mtrr support and noaccel option
@ 2007-07-26 12:23 Antonino A. Daplas
  2007-07-26 20:12 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Antonino A. Daplas @ 2007-07-26 12:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Fbdev development list

From: Krzysztof Helt <krzysztof.h1@wp.pl>

This patch adds usage of MTRR registers and two new options: noaccel and
nomtrr.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
---

 drivers/video/pm3fb.c |   84 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 88af072..3f004e8 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -32,6 +32,9 @@ #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
 
 #include <video/pm3fb.h>
 
@@ -52,6 +55,12 @@ #define PM3_PIXMAP_SIZE	(2048 * 4)
  * Driver data
  */
 static char *mode_option __devinitdata;
+static int noaccel   __devinitdata = 0;
+
+/* mtrr option */
+#ifdef CONFIG_MTRR
+static int nomtrr __devinitdata = 0;
+#endif
 
 /*
  * This structure defines the hardware state of the graphics card. Normally
@@ -65,6 +74,7 @@ struct pm3_par {
 	u32		video;		/* video flags before blanking */
 	u32		base;		/* screen base (xoffset+yoffset) in 128 bits unit */
 	u32		palette[16];
+	int		mtrr_handle;
 };
 
 /*
@@ -788,6 +798,8 @@ #endif /* ! __BIG_ENDIAN */
 /*
  * hardware independent functions
  */
+int pm3fb_init(void);
+
 static int pm3fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
 	u32 lpitch;
@@ -1244,6 +1256,13 @@ #endif
 	}
 	info->screen_size = pm3fb_fix.smem_len;
 
+#ifdef CONFIG_MTRR
+	if (!nomtrr) {
+		par->mtrr_handle = mtrr_add(pm3fb_fix.smem_start,
+						pm3fb_fix.smem_len,
+						MTRR_TYPE_WRCOMB, 1);
+	}
+#endif
 	info->fbops = &pm3fb_ops;
 
 	par->video = PM3_READ_REG(par, PM3VideoControl);
@@ -1257,6 +1276,10 @@ #endif
 			FBINFO_HWACCEL_IMAGEBLIT |
 			FBINFO_HWACCEL_FILLRECT;
 
+	if (noaccel) {
+	    	printk(KERN_DEBUG "disabling acceleration\n");
+  		info->flags |= FBINFO_HWACCEL_DISABLED;
+	}
 	info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL);
 	if (!info->pixmap.addr) {
 		retval = -ENOMEM;
@@ -1330,6 +1353,11 @@ static void __devexit pm3fb_remove(struc
 		unregister_framebuffer(info);
 		fb_dealloc_cmap(&info->cmap);
 
+#ifdef CONFIG_MTRR
+	if (par->mtrr_handle >= 0)
+		mtrr_del(par->mtrr_handle, info->fix.smem_start,
+			 info->fix.smem_len);
+#endif /* CONFIG_MTRR */
 		iounmap(info->screen_base);
 		release_mem_region(fix->smem_start, fix->smem_len);
 		iounmap(par->v_regs);
@@ -1357,22 +1385,72 @@ static struct pci_driver pm3fb_driver = 
 
 MODULE_DEVICE_TABLE(pci, pm3fb_id_table);
 
-static int __init pm3fb_init(void)
+#ifndef MODULE
+	/*
+	 *  Setup
+	 */
+
+/*
+ * Only necessary if your driver takes special options,
+ * otherwise we fall back on the generic fb_setup().
+ */
+static int __init pm3fb_setup(char *options)
+{
+	char *this_opt;
+
+	/* Parse user speficied options (`video=pm3fb:') */
+	if (!options || !*options)
+		return 0;
+
+	while ((this_opt = strsep(&options, ",")) != NULL) {
+		if (!*this_opt)
+			continue;
+		else if (!strncmp(this_opt, "noaccel", 7)) {
+			noaccel = 1;
+#ifdef CONFIG_MTRR
+		} else if (!strncmp(this_opt, "nomtrr", 6)) {
+			nomtrr = 1;
+#endif
+		} else {
+			mode_option = this_opt;
+		}
+	}
+	return 0;
+}
+#endif /* MODULE */
+
+int __init pm3fb_init(void)
 {
+	/*
+	 *  For kernel boot options (in 'video=pm3fb:<options>' format)
+	 */
 #ifndef MODULE
-	if (fb_get_options("pm3fb", NULL))
+	char *option = NULL;
+
+	if (fb_get_options("pm3fb", &option))
 		return -ENODEV;
+	pm3fb_setup(option);
 #endif
+
 	return pci_register_driver(&pm3fb_driver);
 }
 
+#ifdef MODULE
 static void __exit pm3fb_exit(void)
 {
 	pci_unregister_driver(&pm3fb_driver);
 }
 
-module_init(pm3fb_init);
 module_exit(pm3fb_exit);
+#endif
+module_init(pm3fb_init);
+
+module_param(noaccel, bool, 0);
+MODULE_PARM_DESC(noaccel, "Disable acceleration");
+#ifdef CONFIG_MTRR
+module_param(nomtrr, bool, 0);
+MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)");
+#endif
 
 MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
 MODULE_LICENSE("GPL");


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 18/33] pm3fb: mtrr support and noaccel option
  2007-07-26 12:23 [PATCH 18/33] pm3fb: mtrr support and noaccel option Antonino A. Daplas
@ 2007-07-26 20:12 ` Andrew Morton
  2007-07-26 21:51   ` Antonino A. Daplas
  2007-07-27 17:19   ` Krzysztof Helt
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Morton @ 2007-07-26 20:12 UTC (permalink / raw)
  To: Antonino A. Daplas; +Cc: Linux Fbdev development list

On Thu, 26 Jul 2007 20:23:55 +0800 "Antonino A. Daplas" <adaplas@gmail.com> wrote:

> From: Krzysztof Helt <krzysztof.h1@wp.pl>
> 
> This patch adds usage of MTRR registers and two new options: noaccel and
> nomtrr.
> 

It's been tested with CONFIG_MTRR=n, I trust?

> +#ifdef CONFIG_MTRR
> +#include <asm/mtrr.h>
> +#endif

Is the ifdef there needed for a successful compile?  If not, it's nicer to
leave it out.

>  #include <video/pm3fb.h>
>  
> @@ -52,6 +55,12 @@ #define PM3_PIXMAP_SIZE	(2048 * 4)
>   * Driver data
>   */
>  static char *mode_option __devinitdata;
> +static int noaccel   __devinitdata = 0;
> +
> +/* mtrr option */
> +#ifdef CONFIG_MTRR
> +static int nomtrr __devinitdata = 0;

Unneeded initialisation to zero.  scripts/checkpatch.pl detects and reports
this.

> +#ifdef CONFIG_MTRR
> +	if (!nomtrr) {
> +		par->mtrr_handle = mtrr_add(pm3fb_fix.smem_start,
> +						pm3fb_fix.smem_len,
> +						MTRR_TYPE_WRCOMB, 1);
> +	}
> +#endif
>  	info->fbops = &pm3fb_ops;
>  
>  	par->video = PM3_READ_REG(par, PM3VideoControl);
> @@ -1257,6 +1276,10 @@ #endif
>  			FBINFO_HWACCEL_IMAGEBLIT |
>  			FBINFO_HWACCEL_FILLRECT;
>  
> +	if (noaccel) {
> +	    	printk(KERN_DEBUG "disabling acceleration\n");
> +  		info->flags |= FBINFO_HWACCEL_DISABLED;
> +	}
>  	info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL);
>  	if (!info->pixmap.addr) {
>  		retval = -ENOMEM;
> @@ -1330,6 +1353,11 @@ static void __devexit pm3fb_remove(struc
>  		unregister_framebuffer(info);
>  		fb_dealloc_cmap(&info->cmap);
>  
> +#ifdef CONFIG_MTRR
> +	if (par->mtrr_handle >= 0)
> +		mtrr_del(par->mtrr_handle, info->fix.smem_start,
> +			 info->fix.smem_len);
> +#endif /* CONFIG_MTRR */

I suspect that with a bit of thought a lot of these unpleasing ifdefs could
be removed.



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 18/33] pm3fb: mtrr support and noaccel option
  2007-07-26 20:12 ` Andrew Morton
@ 2007-07-26 21:51   ` Antonino A. Daplas
  2007-07-27 17:19   ` Krzysztof Helt
  1 sibling, 0 replies; 5+ messages in thread
From: Antonino A. Daplas @ 2007-07-26 21:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Fbdev development list

On Thu, 2007-07-26 at 13:12 -0700, Andrew Morton wrote:
> On Thu, 26 Jul 2007 20:23:55 +0800 "Antonino A. Daplas" <adaplas@gmail.com> wrote:
> 
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > 
> > This patch adds usage of MTRR registers and two new options: noaccel and
> > nomtrr.
> > 
> 
> It's been tested with CONFIG_MTRR=n, I trust?
> 
> > +#ifdef CONFIG_MTRR
> > +#include <asm/mtrr.h>
> > +#endif
> 
> Is the ifdef there needed for a successful compile?  If not, it's nicer to
> leave it out.

Yes, not all archs have asm/mtrr.h.

Tony



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 18/33] pm3fb: mtrr support and noaccel option
  2007-07-26 20:12 ` Andrew Morton
  2007-07-26 21:51   ` Antonino A. Daplas
@ 2007-07-27 17:19   ` Krzysztof Helt
  2007-07-27 19:33     ` Andrew Morton
  1 sibling, 1 reply; 5+ messages in thread
From: Krzysztof Helt @ 2007-07-27 17:19 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Fbdev development list, Antonino A. Daplas

On Thu, 26 Jul 2007 13:12:38 -0700
Andrew Morton <akpm@linux-foundation.org> wrote:

> On Thu, 26 Jul 2007 20:23:55 +0800 "Antonino A. Daplas" <adaplas@gmail.com> wrote:
> 
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > 
> > This patch adds usage of MTRR registers and two new options: noaccel and
> > nomtrr.
> > 
> 
> It's been tested with CONFIG_MTRR=n, I trust?
> 

Yes, of course. The only thing I haven't tested is compilation on the big-endian machine.

You can reject the patch if you want and will prepare the next version (without issues you pointed out). Or you can accept it and I will fix issues in next patch.

Regards,
Krzysztof

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

* Re: [PATCH 18/33] pm3fb: mtrr support and noaccel option
  2007-07-27 17:19   ` Krzysztof Helt
@ 2007-07-27 19:33     ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2007-07-27 19:33 UTC (permalink / raw)
  To: Krzysztof Helt; +Cc: Linux Fbdev development list, Antonino A. Daplas

On Fri, 27 Jul 2007 19:19:34 +0200
Krzysztof Helt <krzysztof.h1@wp.pl> wrote:

> On Thu, 26 Jul 2007 13:12:38 -0700
> Andrew Morton <akpm@linux-foundation.org> wrote:
> 
> > On Thu, 26 Jul 2007 20:23:55 +0800 "Antonino A. Daplas" <adaplas@gmail.com> wrote:
> > 
> > > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> > > 
> > > This patch adds usage of MTRR registers and two new options: noaccel and
> > > nomtrr.
> > > 
> > 
> > It's been tested with CONFIG_MTRR=n, I trust?
> > 
> 
> Yes, of course. The only thing I haven't tested is compilation on the big-endian machine.
> 
> You can reject the patch if you want and will prepare the next version (without issues you pointed out). Or you can accept it and I will fix issues in next patch.
> 

For minor issues I usually will just merge the patch and will trust the
author to consider and perhaps later fix the issues which were asked about.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

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

end of thread, other threads:[~2007-07-27 19:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-26 12:23 [PATCH 18/33] pm3fb: mtrr support and noaccel option Antonino A. Daplas
2007-07-26 20:12 ` Andrew Morton
2007-07-26 21:51   ` Antonino A. Daplas
2007-07-27 17:19   ` Krzysztof Helt
2007-07-27 19:33     ` Andrew Morton

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