aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2007-10-16 04:28:33 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:14 -0400
commitd5383fcc4c221227b954e028821a697ca7859e0e (patch)
tree36f9bbfb5fd12dd016bfd5f3b17847ef7a6a3aa4
parent0ddf78491ddad301ddcd151de8108146e20398e7 (diff)
pm3fb: mtrr support and noaccel option
This patch adds usage of MTRR registers and two new options: noaccel and nomtrr. [bunk@kernel.org: make pm3fb_init() static again] Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/video/pm2fb.c40
-rw-r--r--drivers/video/pm3fb.c80
2 files changed, 118 insertions, 2 deletions
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
index 10c0cc6e93fc..af615d99d438 100644
--- a/drivers/video/pm2fb.c
+++ b/drivers/video/pm2fb.c
@@ -38,6 +38,9 @@
38#include <linux/fb.h> 38#include <linux/fb.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#ifdef CONFIG_MTRR
42#include <asm/mtrr.h>
43#endif
41 44
42#include <video/permedia2.h> 45#include <video/permedia2.h>
43#include <video/cvisionppc.h> 46#include <video/cvisionppc.h>
@@ -73,6 +76,11 @@ static char *mode __devinitdata = NULL;
73 */ 76 */
74static int lowhsync; 77static int lowhsync;
75static int lowvsync; 78static int lowvsync;
79static int noaccel __devinitdata;
80/* mtrr option */
81#ifdef CONFIG_MTRR
82static int nomtrr __devinitdata;
83#endif
76 84
77/* 85/*
78 * The hardware state of the graphics card that isn't part of the 86 * The hardware state of the graphics card that isn't part of the
@@ -88,6 +96,7 @@ struct pm2fb_par
88 u32 mem_control; /* MemControl reg at probe */ 96 u32 mem_control; /* MemControl reg at probe */
89 u32 boot_address; /* BootAddress reg at probe */ 97 u32 boot_address; /* BootAddress reg at probe */
90 u32 palette[16]; 98 u32 palette[16];
99 int mtrr_handle;
91}; 100};
92 101
93/* 102/*
@@ -1316,6 +1325,15 @@ static int __devinit pm2fb_probe(struct pci_dev *pdev,
1316 goto err_exit_mmio; 1325 goto err_exit_mmio;
1317 } 1326 }
1318 1327
1328#ifdef CONFIG_MTRR
1329 default_par->mtrr_handle = -1;
1330 if (!nomtrr)
1331 default_par->mtrr_handle =
1332 mtrr_add(pm2fb_fix.smem_start,
1333 pm2fb_fix.smem_len,
1334 MTRR_TYPE_WRCOMB, 1);
1335#endif
1336
1319 info->fbops = &pm2fb_ops; 1337 info->fbops = &pm2fb_ops;
1320 info->fix = pm2fb_fix; 1338 info->fix = pm2fb_fix;
1321 info->pseudo_palette = default_par->palette; 1339 info->pseudo_palette = default_par->palette;
@@ -1324,6 +1342,11 @@ static int __devinit pm2fb_probe(struct pci_dev *pdev,
1324 FBINFO_HWACCEL_COPYAREA | 1342 FBINFO_HWACCEL_COPYAREA |
1325 FBINFO_HWACCEL_FILLRECT; 1343 FBINFO_HWACCEL_FILLRECT;
1326 1344
1345 if (noaccel) {
1346 printk(KERN_DEBUG "disabling acceleration\n");
1347 info->flags |= FBINFO_HWACCEL_DISABLED;
1348 }
1349
1327 if (!mode) 1350 if (!mode)
1328 mode = "640x480@60"; 1351 mode = "640x480@60";
1329 1352
@@ -1375,6 +1398,11 @@ static void __devexit pm2fb_remove(struct pci_dev *pdev)
1375 1398
1376 unregister_framebuffer(info); 1399 unregister_framebuffer(info);
1377 1400
1401#ifdef CONFIG_MTRR
1402 if (par->mtrr_handle >= 0)
1403 mtrr_del(par->mtrr_handle, info->fix.smem_start,
1404 info->fix.smem_len);
1405#endif /* CONFIG_MTRR */
1378 iounmap(info->screen_base); 1406 iounmap(info->screen_base);
1379 release_mem_region(fix->smem_start, fix->smem_len); 1407 release_mem_region(fix->smem_start, fix->smem_len);
1380 iounmap(par->v_regs); 1408 iounmap(par->v_regs);
@@ -1430,6 +1458,12 @@ static int __init pm2fb_setup(char *options)
1430 lowhsync = 1; 1458 lowhsync = 1;
1431 } else if(!strcmp(this_opt, "lowvsync")) { 1459 } else if(!strcmp(this_opt, "lowvsync")) {
1432 lowvsync = 1; 1460 lowvsync = 1;
1461#ifdef CONFIG_MTRR
1462 } else if (!strncmp(this_opt, "nomtrr", 6)) {
1463 nomtrr = 1;
1464#endif
1465 } else if (!strncmp(this_opt, "noaccel", 7)) {
1466 noaccel = 1;
1433 } else { 1467 } else {
1434 mode = this_opt; 1468 mode = this_opt;
1435 } 1469 }
@@ -1474,6 +1508,12 @@ module_param(lowhsync, bool, 0);
1474MODULE_PARM_DESC(lowhsync, "Force horizontal sync low regardless of mode"); 1508MODULE_PARM_DESC(lowhsync, "Force horizontal sync low regardless of mode");
1475module_param(lowvsync, bool, 0); 1509module_param(lowvsync, bool, 0);
1476MODULE_PARM_DESC(lowvsync, "Force vertical sync low regardless of mode"); 1510MODULE_PARM_DESC(lowvsync, "Force vertical sync low regardless of mode");
1511module_param(noaccel, bool, 0);
1512MODULE_PARM_DESC(noaccel, "Disable acceleration");
1513#ifdef CONFIG_MTRR
1514module_param(nomtrr, bool, 0);
1515MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)");
1516#endif
1477 1517
1478MODULE_AUTHOR("Jim Hague <jim.hague@acm.org>"); 1518MODULE_AUTHOR("Jim Hague <jim.hague@acm.org>");
1479MODULE_DESCRIPTION("Permedia2 framebuffer device driver"); 1519MODULE_DESCRIPTION("Permedia2 framebuffer device driver");
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 88af0721f305..195bcdbc66b5 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -32,6 +32,9 @@
32#include <linux/fb.h> 32#include <linux/fb.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#ifdef CONFIG_MTRR
36#include <asm/mtrr.h>
37#endif
35 38
36#include <video/pm3fb.h> 39#include <video/pm3fb.h>
37 40
@@ -52,6 +55,12 @@
52 * Driver data 55 * Driver data
53 */ 56 */
54static char *mode_option __devinitdata; 57static char *mode_option __devinitdata;
58static int noaccel __devinitdata = 0;
59
60/* mtrr option */
61#ifdef CONFIG_MTRR
62static int nomtrr __devinitdata = 0;
63#endif
55 64
56/* 65/*
57 * This structure defines the hardware state of the graphics card. Normally 66 * This structure defines the hardware state of the graphics card. Normally
@@ -65,6 +74,7 @@ struct pm3_par {
65 u32 video; /* video flags before blanking */ 74 u32 video; /* video flags before blanking */
66 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */ 75 u32 base; /* screen base (xoffset+yoffset) in 128 bits unit */
67 u32 palette[16]; 76 u32 palette[16];
77 int mtrr_handle;
68}; 78};
69 79
70/* 80/*
@@ -1244,6 +1254,13 @@ static int __devinit pm3fb_probe(struct pci_dev *dev,
1244 } 1254 }
1245 info->screen_size = pm3fb_fix.smem_len; 1255 info->screen_size = pm3fb_fix.smem_len;
1246 1256
1257#ifdef CONFIG_MTRR
1258 if (!nomtrr) {
1259 par->mtrr_handle = mtrr_add(pm3fb_fix.smem_start,
1260 pm3fb_fix.smem_len,
1261 MTRR_TYPE_WRCOMB, 1);
1262 }
1263#endif
1247 info->fbops = &pm3fb_ops; 1264 info->fbops = &pm3fb_ops;
1248 1265
1249 par->video = PM3_READ_REG(par, PM3VideoControl); 1266 par->video = PM3_READ_REG(par, PM3VideoControl);
@@ -1257,6 +1274,10 @@ static int __devinit pm3fb_probe(struct pci_dev *dev,
1257 FBINFO_HWACCEL_IMAGEBLIT | 1274 FBINFO_HWACCEL_IMAGEBLIT |
1258 FBINFO_HWACCEL_FILLRECT; 1275 FBINFO_HWACCEL_FILLRECT;
1259 1276
1277 if (noaccel) {
1278 printk(KERN_DEBUG "disabling acceleration\n");
1279 info->flags |= FBINFO_HWACCEL_DISABLED;
1280 }
1260 info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL); 1281 info->pixmap.addr = kmalloc(PM3_PIXMAP_SIZE, GFP_KERNEL);
1261 if (!info->pixmap.addr) { 1282 if (!info->pixmap.addr) {
1262 retval = -ENOMEM; 1283 retval = -ENOMEM;
@@ -1330,6 +1351,11 @@ static void __devexit pm3fb_remove(struct pci_dev *dev)
1330 unregister_framebuffer(info); 1351 unregister_framebuffer(info);
1331 fb_dealloc_cmap(&info->cmap); 1352 fb_dealloc_cmap(&info->cmap);
1332 1353
1354#ifdef CONFIG_MTRR
1355 if (par->mtrr_handle >= 0)
1356 mtrr_del(par->mtrr_handle, info->fix.smem_start,
1357 info->fix.smem_len);
1358#endif /* CONFIG_MTRR */
1333 iounmap(info->screen_base); 1359 iounmap(info->screen_base);
1334 release_mem_region(fix->smem_start, fix->smem_len); 1360 release_mem_region(fix->smem_start, fix->smem_len);
1335 iounmap(par->v_regs); 1361 iounmap(par->v_regs);
@@ -1357,22 +1383,72 @@ static struct pci_driver pm3fb_driver = {
1357 1383
1358MODULE_DEVICE_TABLE(pci, pm3fb_id_table); 1384MODULE_DEVICE_TABLE(pci, pm3fb_id_table);
1359 1385
1386#ifndef MODULE
1387 /*
1388 * Setup
1389 */
1390
1391/*
1392 * Only necessary if your driver takes special options,
1393 * otherwise we fall back on the generic fb_setup().
1394 */
1395static int __init pm3fb_setup(char *options)
1396{
1397 char *this_opt;
1398
1399 /* Parse user speficied options (`video=pm3fb:') */
1400 if (!options || !*options)
1401 return 0;
1402
1403 while ((this_opt = strsep(&options, ",")) != NULL) {
1404 if (!*this_opt)
1405 continue;
1406 else if (!strncmp(this_opt, "noaccel", 7)) {
1407 noaccel = 1;
1408#ifdef CONFIG_MTRR
1409 } else if (!strncmp(this_opt, "nomtrr", 6)) {
1410 nomtrr = 1;
1411#endif
1412 } else {
1413 mode_option = this_opt;
1414 }
1415 }
1416 return 0;
1417}
1418#endif /* MODULE */
1419
1360static int __init pm3fb_init(void) 1420static int __init pm3fb_init(void)
1361{ 1421{
1422 /*
1423 * For kernel boot options (in 'video=pm3fb:<options>' format)
1424 */
1362#ifndef MODULE 1425#ifndef MODULE
1363 if (fb_get_options("pm3fb", NULL)) 1426 char *option = NULL;
1427
1428 if (fb_get_options("pm3fb", &option))
1364 return -ENODEV; 1429 return -ENODEV;
1430 pm3fb_setup(option);
1365#endif 1431#endif
1432
1366 return pci_register_driver(&pm3fb_driver); 1433 return pci_register_driver(&pm3fb_driver);
1367} 1434}
1368 1435
1436#ifdef MODULE
1369static void __exit pm3fb_exit(void) 1437static void __exit pm3fb_exit(void)
1370{ 1438{
1371 pci_unregister_driver(&pm3fb_driver); 1439 pci_unregister_driver(&pm3fb_driver);
1372} 1440}
1373 1441
1374module_init(pm3fb_init);
1375module_exit(pm3fb_exit); 1442module_exit(pm3fb_exit);
1443#endif
1444module_init(pm3fb_init);
1445
1446module_param(noaccel, bool, 0);
1447MODULE_PARM_DESC(noaccel, "Disable acceleration");
1448#ifdef CONFIG_MTRR
1449module_param(nomtrr, bool, 0);
1450MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)");
1451#endif
1376 1452
1377MODULE_DESCRIPTION("Permedia3 framebuffer device driver"); 1453MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
1378MODULE_LICENSE("GPL"); 1454MODULE_LICENSE("GPL");