All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Big-endian fixes for tdfxfb in 2.4.21
@ 2003-07-19  6:39 ` Richard Drummond
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Drummond @ 2003-07-19  6:39 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

The following patch fixes some long-standing problems that I have been 
experiencing with the tdfxfb driver in kernel 2.4 when running on a PPC Mac.

Specifically, it fixes:

1) Endian problems when blitting font glyphs. I have enabled byte-swizzling 
when blitting, so text on the console is now readable.

2) Endian issues with 24-bit framebuffer. I've disabled byte-swizzled access 
to 24-bit framebuffers. This now suits the byte-ordering of framebuffers with 
this depth (at least on my hardware).

3) Endian problems with hwcursor. The cursor should now appear at the cursor 
position, that is, actually at the insertion point. It was simply a question 
of getting the right byte-ordering for each framebuffer depth.

4) Disabled I/O ports when booting from OF (rather than via MacOS) preventing 
use. The driver  now calls pci_enable_device() during init - which should 
enable I/O ports - and checks to see that I/O space is accessible before 
proceeding.

I've tested this patch extensively both on a Voodoo3 and a Voodoo4 on several 
(OldWorld) Macs. I don't have an x86 3dfx card to verify that it still works 
there, but the changes shouldn't affect little-endian machines at all.

A couple of problems still remain:

1) Resource management still needs to be implemented (A corollary is that offb 
will claim the card before tdfxfb - if you have the offb driver built in as 
well - and then tdfxfb will also claim it. Solution: you need to supply the 
kernel option video=offb:off to use tdfxfb). This will be trivial to do.

2) Hardware cursor works fine if I boot via MacOS with BootX, but is invisible 
if I boot from OF with Quik. Not sure why - still needs investigation. 
Solution: turn off hwcursor. (Make that kernel option above 
video=offb:off,tdfx:nohwcursor=1 if you boot from OF.)

3) Memory on Voodoo4 is incorrectly detected. It reports 64MB, but the Voodoo4 
only has 32MB. I don't have any documentation on the Voodoo4/5, so I don't 
know the proper way to detect it.  XFree86 uses the same algorithm as tdfxfb, 
so also gets it wrong.

I have taken a cursory glance at the tdfxfb in 2.5/2.6-test and similar 
changes will need to be applied there too. I intend to look at this when I 
have time.

I'd welcome comments on this patch, particulary from anybody running tdfxfb on 
a big-endian platform other than the Mac.

Cheers,
Rich


[-- Attachment #2: tdfxfb-20030719.diff --]
[-- Type: text/x-diff, Size: 2976 bytes --]

--- drivers/video/tdfxfb.c.orig	2003-06-27 08:49:54.000000000 -0500
+++ drivers/video/tdfxfb.c	2003-07-18 16:25:56.000000000 -0500
@@ -764,7 +764,11 @@
    tdfx_outl(SRCXY,     0);
    tdfx_outl(DSTXY,     xx | (yy << 16));
    tdfx_outl(COMMAND_2D, COMMAND_2D_H2S_BITBLT | (ROP_COPY << 24));
+#ifdef __BIG_ENDIAN
+   tdfx_outl(SRCFORMAT, 0x400000 | BIT(20) );   
+#else
    tdfx_outl(SRCFORMAT, 0x400000);
+#endif
    tdfx_outl(DSTFORMAT, fmt);
    tdfx_outl(DSTSIZE,   fontwidth(p) | (fontheight(p) << 16));
    i=fontheight(p);
@@ -822,7 +826,11 @@
    tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
    tdfx_outl(COLORFORE, fgx);
    tdfx_outl(COLORBACK, bgx);
+#ifdef __BIG_ENDIAN
+   tdfx_outl(SRCFORMAT, 0x400000 | BIT(20) );   
+#else
    tdfx_outl(SRCFORMAT, 0x400000);
+#endif   
    tdfx_outl(DSTFORMAT, fmt);
    tdfx_outl(DSTSIZE, w | (h << 16));
    tdfx_outl(SRCXY,     0);
@@ -1475,6 +1483,7 @@
 #if defined(__BIG_ENDIAN)
   switch (par->bpp) {
     case 8:
+    case 24:
       reg.miscinit0 &= ~(1 << 30);
       reg.miscinit0 &= ~(1 << 31);
       break;
@@ -1482,7 +1491,6 @@
       reg.miscinit0 |= (1 << 30);
       reg.miscinit0 |= (1 << 31);
       break;
-    case 24:
     case 32:
       reg.miscinit0 |= (1 << 30);
       reg.miscinit0 &= ~(1 << 31);
@@ -1635,10 +1643,6 @@
     v.blue.length  = 5;
     break;
   case 24:
-    v.red.offset=16;
-    v.green.offset=8;
-    v.blue.offset=0;
-    v.red.length = v.green.length = v.blue.length = 8;
   case 32:
     v.red.offset   = 16;
     v.green.offset = 8;
@@ -1942,6 +1946,12 @@
 			break;
 	}
 	
+        if (pci_enable_device(pdev)) 
+        {
+                printk(KERN_WARNING "fb: Unable to enable %s PCI device.\n", name);
+                return -ENXIO;
+        }
+
 	fb_info.regbase_phys = pci_resource_start(pdev, 0);
 	fb_info.regbase_size = 1 << 24;
 	fb_info.regbase_virt = ioremap_nocache(fb_info.regbase_phys, 1 << 24);
@@ -1970,6 +1980,13 @@
 
 	fb_info.iobase = pci_resource_start (pdev, 2);
       
+        if (!fb_info.iobase) {
+	        printk(KERN_WARNING "fb: Can't access %s I/O ports.\n", name);
+		iounmap(fb_info.regbase_virt);
+		iounmap(fb_info.bufbase_virt);
+                return -ENXIO;
+	}
+   
 	printk("fb: %s memory = %ldK\n", name, fb_info.bufbase_size >> 10);
 
 #ifdef CONFIG_MTRR
@@ -2363,10 +2380,25 @@
    unsigned int h,to;
 
    tdfxfb_createcursorshape(p);
-   xline = ~((1 << (32 - fb_info.cursor.w)) - 1);
+   xline = (~0) << (32 - fb_info.cursor.w);
 
 #ifdef __LITTLE_ENDIAN
    xline = swab32(xline);
+#else
+   switch (p->var.bits_per_pixel) {
+      case 8:
+      case 24:
+         xline = swab32(xline);
+         break;
+      case 16:
+         xline = ((xline & 0xff000000 ) >> 16 )
+               | ((xline & 0x00ff0000 ) >> 16 )
+               | ((xline & 0x0000ff00 ) << 16 )
+               | ((xline & 0x000000ff ) << 16 );
+         break;
+      case 32:
+         break;
+   }
 #endif
 
    cursorbase=(u8*)fb_info.bufbase_virt;

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

* [PATCH] Big-endian fixes for tdfxfb in 2.4.21
@ 2003-07-19  6:39 ` Richard Drummond
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Drummond @ 2003-07-19  6:39 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

The following patch fixes some long-standing problems that I have been 
experiencing with the tdfxfb driver in kernel 2.4 when running on a PPC Mac.

Specifically, it fixes:

1) Endian problems when blitting font glyphs. I have enabled byte-swizzling 
when blitting, so text on the console is now readable.

2) Endian issues with 24-bit framebuffer. I've disabled byte-swizzled access 
to 24-bit framebuffers. This now suits the byte-ordering of framebuffers with 
this depth (at least on my hardware).

3) Endian problems with hwcursor. The cursor should now appear at the cursor 
position, that is, actually at the insertion point. It was simply a question 
of getting the right byte-ordering for each framebuffer depth.

4) Disabled I/O ports when booting from OF (rather than via MacOS) preventing 
use. The driver  now calls pci_enable_device() during init - which should 
enable I/O ports - and checks to see that I/O space is accessible before 
proceeding.

I've tested this patch extensively both on a Voodoo3 and a Voodoo4 on several 
(OldWorld) Macs. I don't have an x86 3dfx card to verify that it still works 
there, but the changes shouldn't affect little-endian machines at all.

A couple of problems still remain:

1) Resource management still needs to be implemented (A corollary is that offb 
will claim the card before tdfxfb - if you have the offb driver built in as 
well - and then tdfxfb will also claim it. Solution: you need to supply the 
kernel option video=offb:off to use tdfxfb). This will be trivial to do.

2) Hardware cursor works fine if I boot via MacOS with BootX, but is invisible 
if I boot from OF with Quik. Not sure why - still needs investigation. 
Solution: turn off hwcursor. (Make that kernel option above 
video=offb:off,tdfx:nohwcursor=1 if you boot from OF.)

3) Memory on Voodoo4 is incorrectly detected. It reports 64MB, but the Voodoo4 
only has 32MB. I don't have any documentation on the Voodoo4/5, so I don't 
know the proper way to detect it.  XFree86 uses the same algorithm as tdfxfb, 
so also gets it wrong.

I have taken a cursory glance at the tdfxfb in 2.5/2.6-test and similar 
changes will need to be applied there too. I intend to look at this when I 
have time.

I'd welcome comments on this patch, particulary from anybody running tdfxfb on 
a big-endian platform other than the Mac.

Cheers,
Rich


[-- Attachment #2: tdfxfb-20030719.diff --]
[-- Type: text/x-diff, Size: 2976 bytes --]

--- drivers/video/tdfxfb.c.orig	2003-06-27 08:49:54.000000000 -0500
+++ drivers/video/tdfxfb.c	2003-07-18 16:25:56.000000000 -0500
@@ -764,7 +764,11 @@
    tdfx_outl(SRCXY,     0);
    tdfx_outl(DSTXY,     xx | (yy << 16));
    tdfx_outl(COMMAND_2D, COMMAND_2D_H2S_BITBLT | (ROP_COPY << 24));
+#ifdef __BIG_ENDIAN
+   tdfx_outl(SRCFORMAT, 0x400000 | BIT(20) );   
+#else
    tdfx_outl(SRCFORMAT, 0x400000);
+#endif
    tdfx_outl(DSTFORMAT, fmt);
    tdfx_outl(DSTSIZE,   fontwidth(p) | (fontheight(p) << 16));
    i=fontheight(p);
@@ -822,7 +826,11 @@
    tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
    tdfx_outl(COLORFORE, fgx);
    tdfx_outl(COLORBACK, bgx);
+#ifdef __BIG_ENDIAN
+   tdfx_outl(SRCFORMAT, 0x400000 | BIT(20) );   
+#else
    tdfx_outl(SRCFORMAT, 0x400000);
+#endif   
    tdfx_outl(DSTFORMAT, fmt);
    tdfx_outl(DSTSIZE, w | (h << 16));
    tdfx_outl(SRCXY,     0);
@@ -1475,6 +1483,7 @@
 #if defined(__BIG_ENDIAN)
   switch (par->bpp) {
     case 8:
+    case 24:
       reg.miscinit0 &= ~(1 << 30);
       reg.miscinit0 &= ~(1 << 31);
       break;
@@ -1482,7 +1491,6 @@
       reg.miscinit0 |= (1 << 30);
       reg.miscinit0 |= (1 << 31);
       break;
-    case 24:
     case 32:
       reg.miscinit0 |= (1 << 30);
       reg.miscinit0 &= ~(1 << 31);
@@ -1635,10 +1643,6 @@
     v.blue.length  = 5;
     break;
   case 24:
-    v.red.offset=16;
-    v.green.offset=8;
-    v.blue.offset=0;
-    v.red.length = v.green.length = v.blue.length = 8;
   case 32:
     v.red.offset   = 16;
     v.green.offset = 8;
@@ -1942,6 +1946,12 @@
 			break;
 	}
 	
+        if (pci_enable_device(pdev)) 
+        {
+                printk(KERN_WARNING "fb: Unable to enable %s PCI device.\n", name);
+                return -ENXIO;
+        }
+
 	fb_info.regbase_phys = pci_resource_start(pdev, 0);
 	fb_info.regbase_size = 1 << 24;
 	fb_info.regbase_virt = ioremap_nocache(fb_info.regbase_phys, 1 << 24);
@@ -1970,6 +1980,13 @@
 
 	fb_info.iobase = pci_resource_start (pdev, 2);
       
+        if (!fb_info.iobase) {
+	        printk(KERN_WARNING "fb: Can't access %s I/O ports.\n", name);
+		iounmap(fb_info.regbase_virt);
+		iounmap(fb_info.bufbase_virt);
+                return -ENXIO;
+	}
+   
 	printk("fb: %s memory = %ldK\n", name, fb_info.bufbase_size >> 10);
 
 #ifdef CONFIG_MTRR
@@ -2363,10 +2380,25 @@
    unsigned int h,to;
 
    tdfxfb_createcursorshape(p);
-   xline = ~((1 << (32 - fb_info.cursor.w)) - 1);
+   xline = (~0) << (32 - fb_info.cursor.w);
 
 #ifdef __LITTLE_ENDIAN
    xline = swab32(xline);
+#else
+   switch (p->var.bits_per_pixel) {
+      case 8:
+      case 24:
+         xline = swab32(xline);
+         break;
+      case 16:
+         xline = ((xline & 0xff000000 ) >> 16 )
+               | ((xline & 0x00ff0000 ) >> 16 )
+               | ((xline & 0x0000ff00 ) << 16 )
+               | ((xline & 0x000000ff ) << 16 );
+         break;
+      case 32:
+         break;
+   }
 #endif
 
    cursorbase=(u8*)fb_info.bufbase_virt;

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

* Re: [Linux-fbdev-devel] [PATCH] Big-endian fixes for tdfxfb in 2.4.21
  2003-07-19  6:39 ` Richard Drummond
@ 2003-07-19  9:34   ` Richard Drummond
  -1 siblings, 0 replies; 8+ messages in thread
From: Richard Drummond @ 2003-07-19  9:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Linux Kernel Mailing List

On Saturday 19 July 2003 01:39 am, Richard Drummond wrote:
> I've tested this patch extensively both on a Voodoo3 and a Voodoo4 . . .

Ooops. I apologize. It turns out that I didn't test this as thoroughly as I 
had thought. Although the Voodoo3 works perfectly, 16-bit and 32-bit modes  
are still broken on the Voodoo4.

Does anybody have docs on the Voodoo4/5 or know how byte-swizzling woks on 
these cards? It definitely doesn't behave the same as the Voodoo3 . . .

If nobody objects, the patch I posted previously should still be applied to 
2.4 since it does fix all the endian problems in tdfxfb with the Voodoo3.

Cheers,
Rich


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

* Re: [Linux-fbdev-devel] [PATCH] Big-endian fixes for tdfxfb in 2.4.21
@ 2003-07-19  9:34   ` Richard Drummond
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Drummond @ 2003-07-19  9:34 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: Linux Kernel Mailing List

On Saturday 19 July 2003 01:39 am, Richard Drummond wrote:
> I've tested this patch extensively both on a Voodoo3 and a Voodoo4 . . .

Ooops. I apologize. It turns out that I didn't test this as thoroughly as I 
had thought. Although the Voodoo3 works perfectly, 16-bit and 32-bit modes  
are still broken on the Voodoo4.

Does anybody have docs on the Voodoo4/5 or know how byte-swizzling woks on 
these cards? It definitely doesn't behave the same as the Voodoo3 . . .

If nobody objects, the patch I posted previously should still be applied to 
2.4 since it does fix all the endian problems in tdfxfb with the Voodoo3.

Cheers,
Rich

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

* Re: [Linux-fbdev-devel] [PATCH] Big-endian fixes for tdfxfb in 2.4.21
  2003-07-19  9:34   ` Richard Drummond
@ 2003-07-24 23:41     ` James Simmons
  -1 siblings, 0 replies; 8+ messages in thread
From: James Simmons @ 2003-07-24 23:41 UTC (permalink / raw)
  To: Richard Drummond; +Cc: linux-fbdev-devel, Linux Kernel Mailing List


> Ooops. I apologize. It turns out that I didn't test this as thoroughly as I 
> had thought. Although the Voodoo3 works perfectly, 16-bit and 32-bit modes  
> are still broken on the Voodoo4.

I have a Voodoo 5 so I can give it a try this week end. I don't have docs 
on the latest cards. I will apply the patch to 2.5.X this weekend.





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

* Re: [PATCH] Big-endian fixes for tdfxfb in 2.4.21
@ 2003-07-24 23:41     ` James Simmons
  0 siblings, 0 replies; 8+ messages in thread
From: James Simmons @ 2003-07-24 23:41 UTC (permalink / raw)
  To: Richard Drummond; +Cc: linux-fbdev-devel, Linux Kernel Mailing List


> Ooops. I apologize. It turns out that I didn't test this as thoroughly as I 
> had thought. Although the Voodoo3 works perfectly, 16-bit and 32-bit modes  
> are still broken on the Voodoo4.

I have a Voodoo 5 so I can give it a try this week end. I don't have docs 
on the latest cards. I will apply the patch to 2.5.X this weekend.






-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01

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

* Re: [Linux-fbdev-devel] [PATCH] Big-endian fixes for tdfxfb in 2.4.21
  2003-07-24 23:41     ` James Simmons
@ 2003-07-25  2:53       ` Richard Drummond
  -1 siblings, 0 replies; 8+ messages in thread
From: Richard Drummond @ 2003-07-25  2:53 UTC (permalink / raw)
  To: James Simmons; +Cc: linux-fbdev-devel, Linux Kernel Mailing List

Hi James

On Thursday 24 July 2003 06:41 pm, James Simmons wrote:
> > Ooops. I apologize. It turns out that I didn't test this as thoroughly as
> > I had thought. Although the Voodoo3 works perfectly, 16-bit and 32-bit
> > modes are still broken on the Voodoo4.
>
> I have a Voodoo 5 so I can give it a try this week end. I don't have docs
> on the latest cards. I will apply the patch to 2.5.X this weekend.

I have been doing some experimenting with the Voodoo4 on my Mac, and I have 
made a little progress. By doing register dumps and general snooping about to 
discover how MacOS sets up the card, I've found that the card actually 
supports a big-endian aperture on the framebuffer (this is different from how 
big-endian support works on the Voodoo3). As I don't have docs, there's a lot 
of guess-work involved, and I haven't got it working 100% reliably yet - but 
once I do I'll supply a patch.

I'm also working on getting the hwcursor working. The patch I produced against 
2.4.21 does contain fixes for the hwcursor on the Voodoo3 for big-endian 
machines. Again, though, because the different way byte-swizzling works on 
the Voodoo4/5, it doesn't work there in 16- and 32-bit modes. When I get the 
big-endian fixes for the Voodoo4/5 finished, I'll have look at the hwcursor 
on 2.5/2.6 . . . 

Cheers,
Rich


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

* Re: [PATCH] Big-endian fixes for tdfxfb in 2.4.21
@ 2003-07-25  2:53       ` Richard Drummond
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Drummond @ 2003-07-25  2:53 UTC (permalink / raw)
  To: James Simmons; +Cc: linux-fbdev-devel, Linux Kernel Mailing List

Hi James

On Thursday 24 July 2003 06:41 pm, James Simmons wrote:
> > Ooops. I apologize. It turns out that I didn't test this as thoroughly as
> > I had thought. Although the Voodoo3 works perfectly, 16-bit and 32-bit
> > modes are still broken on the Voodoo4.
>
> I have a Voodoo 5 so I can give it a try this week end. I don't have docs
> on the latest cards. I will apply the patch to 2.5.X this weekend.

I have been doing some experimenting with the Voodoo4 on my Mac, and I have 
made a little progress. By doing register dumps and general snooping about to 
discover how MacOS sets up the card, I've found that the card actually 
supports a big-endian aperture on the framebuffer (this is different from how 
big-endian support works on the Voodoo3). As I don't have docs, there's a lot 
of guess-work involved, and I haven't got it working 100% reliably yet - but 
once I do I'll supply a patch.

I'm also working on getting the hwcursor working. The patch I produced against 
2.4.21 does contain fixes for the hwcursor on the Voodoo3 for big-endian 
machines. Again, though, because the different way byte-swizzling works on 
the Voodoo4/5, it doesn't work there in 16- and 32-bit modes. When I get the 
big-endian fixes for the Voodoo4/5 finished, I'll have look at the hwcursor 
on 2.5/2.6 . . . 

Cheers,
Rich



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01

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

end of thread, other threads:[~2003-07-25  2:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-19  6:39 [PATCH] Big-endian fixes for tdfxfb in 2.4.21 Richard Drummond
2003-07-19  6:39 ` Richard Drummond
2003-07-19  9:34 ` [Linux-fbdev-devel] " Richard Drummond
2003-07-19  9:34   ` Richard Drummond
2003-07-24 23:41   ` James Simmons
2003-07-24 23:41     ` James Simmons
2003-07-25  2:53     ` [Linux-fbdev-devel] " Richard Drummond
2003-07-25  2:53       ` Richard Drummond

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.