voodoo5 tdfxfb mmap problems

Marlon de Boer <[email protected]>
Newsgroups gmane.linux.fbdev.user
Message-ID <[email protected]>
I'm trying to get mplayer to work with tdfxfb on a 2.6 kernel, when looking at 
the source I found out that

	/* Open up a window to the hardware */
        memBase1 = mmap(0, fb_finfo.smem_len, PROT_READ | PROT_WRITE,
                                        MAP_SHARED, fd, 0);
        memBase0 = mmap(0, fb_finfo.mmio_len, PROT_READ | PROT_WRITE,
                                        MAP_SHARED, fd, fb_finfo.smem_len);

was causing the problem. The second mmap (memBase0) returned EINVAL. 

man mmap says " EINVAL We don't like start or length or offset.  (E.g., they 
are too large, or not aligned on  a  PAGE-SIZE boundary".

So I thought that it must be some problem with the mmio mem length. I wrote a 
small program that printed out some of the fb_fix_screeninfo structure.

smem_start d0000000 
mmio_start d8000000 
mmio_len 67108864 (64Mb)
smem_len 33554432 (32Mb)

My voodoo5 has 2 gpu's each with 32Mb memory (according to the hardware 
specs).

lspci:

0000:01:00.0 VGA compatible controller: 3Dfx Interactive, Inc. Voodoo 4 / 
Voodoo 5 (rev 01) (prog-if 00 [VGA])
        Subsystem: 3Dfx Interactive, Inc.: Unknown device 0002
        Flags: 66Mhz, fast devsel, IRQ 16
        Memory at d8000000 (32-bit, non-prefetchable)
        Memory at d0000000 (32-bit, prefetchable) [size=128M]
        I/O ports at a000 [size=256]
        Capabilities: [54] AGP version 2.0
        Capabilities: [60] Power Management version 2

dmesg:

ACPI: PCI Interrupt 0000:01:00.0[A] -> GSI 16 (level, low) -> IRQ 16
fb: 3Dfx Voodoo5 memory = 32768K
Console: switching to colour frame buffer device 80x30

/proc/mtrr

reg00: base=0x00000000 (   0MB), size= 128MB: write-back, count=1
reg01: base=0xd0000000 (3328MB), size=  64MB: write-combining, count=2

Some useful info from Xorg.0.log

II) TDFX(0): Softbooting the board (through the int10 interface).
(EE) TDFX(0): shmget(lowmem) error: Unknown error 999
(WW) TDFX(0): Softbooting the board failed.
(II) TDFX(0): TDFXFindChips: found 1 chip(s)
(**) TDFX(0): Depth 24, (--) framebuffer bpp 32
(==) TDFX(0): RGB weight 888
(==) TDFX(0): Default visual is TrueColor
(--) TDFX(0): Chipset: "3dfx Voodoo5"
(--) TDFX(0): Linear framebuffer at 0xD0000000
(--) TDFX(0): MMIO registers at addr 0xD8000000
(--) TDFX(0): PIO registers at addr 0xA000
(II) TDFX(0): DRAMINIT1 read 0x40240031, programming 0x40202031 (not Banshee)
(II) TDFX(0): TDFXInitChips: numchips = 1
(II) TDFX(0): TDFXInitChips: cfgbits = 0x00000004, initbits = 0x00000301
(II) TDFX(0): TDFXInitChips: mem0base = 0xd8000000, mem1base = 0xd0000008
(II) TDFX(0): TDFXInitChips: mem0size = 0x02000000, mem1size = 0x04000000
(II) TDFX(0): TDFXInitChips: mem0bits = 0x00000005, mem1bits = 0x00000040
(II) TDFX(0): TDFXInitChips: cfgbits = 0x00000045
(II) TDFX(0): TDFXInitChips: MMIOAddr[0] = 0xd8000000
(II) TDFX(0): TDFXInitChips: LinearAddr[0] = 0xd0000008
(--) TDFX(0): VideoRAM: 32768 kByte Mapping 65536 kByte

(==) TDFX(0): Write-combining range (0xd0000000,0x4000000)
(II) TDFX(0): vgaHWGetIOBase: hwp->IOBase is 0x03d0, hwp->PIOOffset is 0x9d00
(II) TDFX(0): Changing back offset from 0x019ff000 to 0x019fe000
(II) TDFX(0): Textures Memory 21.42 MB
(II) TDFX(0): Cursor Offset: [0x00000000,0x00001000)
(II) TDFX(0): Fifo Offset: [0x00001000, 0x00041000)
(II) TDFX(0): Front Buffer Offset: [0x00041000, 0x00493000)
(II) TDFX(0): Texture Offset: [0x00493000, 0x019FE000)
(II) TDFX(0): BackOffset: [0x019FE000, 0x01CFE000)
(II) TDFX(0): DepthOffset: [0x01CFF000, 0x01FFF000)
(II) TDFX(0): Minimum 338, Maximum 3327 lines of offscreen memory available
(II) TDFX(0): [dri] VideoRAM = 32768, VirtualXres = 1024, VirtualYres= 768,

I'm running Linux freakypeople 2.6.11.6-grsec #1 SMP Wed Mar 30 09:48:16 CEST 
2005 i686 Pentium III (Coppermine) GenuineIntel GNU/Linux

I know that's kind of old hardware and 3dfx is dead for long time now, but 
does anybody has an idea how I prevent

memBase0 = mmap(0, fb_finfo.mmio_len, PROT_READ | PROT_WRITE,
                                        MAP_SHARED, fd, fb_finfo.smem_len);

from returning EINVAL? I'm not really a framebuffer / graphics programmer, so 
I don't know much about the internal functions of the framebuffer, (did a 
quick scan of the tdfxfb source in the kernel though). My guess is I'm 
mmapping the wrong area. I tried to change memBase0 to

memBase0 = mmap((unsigned long *)&fb_finfo.mmio_start, fb_finfo.mmio_len, 
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); , without any luck

from the mmap man

The  mmap() function asks to map length bytes starting at offset offset from 
the file (or other object) specified by the file descriptor fd into memory, 
preferably at address start.  This latter address is a  hint  only,  and is 
usually specified as 0.  

So I did an strace on my program and found out that mmap didn't use the hint 
at all.

Anybody an idea?

Regards,

Marlon.


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.