Thread (13 messages) 13 messages, 4 authors, 2003-09-12

Re: New API and X option UseFBDev

flat view

From: Jim Hague <hidden>
Date: 2003-09-09 22:59:57

On 09-Sep-2003 Sven Luther wrote:
Mmm, notice that the :

(--) GLINT(0): Linear framebuffer at 0xCE800000
(--) GLINT(0): MMIO registers at 0xCFFE0000
(EE) GLINT(0): mmap mmio: Invalid argument
(EE) GLINT(0): mmap mmio: Invalid argument

means that the linear framebuffer and mmio registers, values given to
you by pm2fb, are correct (but check this fact with lspci). GLINTMapMem
should call fbdevHWMapVidmem, so i suppose the message you see are from
fbdevhw. Try enabling the DEBUG #define in glint_driver.c to get a bit
more context. 
I'd notice that. The code in question is in fbdevhw.c.

I've abstracted the problem out into the test program below. It mimics what
fbdehhw.c does, namely open the frame buffer device, get the fix screen info
and (I'm assuming) mmap() the io (I haven't delved through the detail
of /dev/fb0).

I've run this on 2.4.22-pre6-ac1 and it works fine, and by implication, since
X via UseFBDev has worked since then, since early 2.4. Here's the output:

PAGE_MASK 0xfffff000, ~PAGE_MASK 0xfff
smem_start 0xcf000000 smem_len 0x400000, mmio_start 0xcffe0000, mmio_len 0x10000
fb_off 0x0 fb_len 0x400000, mmio_off 0x0, mmio_len 0x10000
mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, 3, 0x400000)
Worked - map 0x40016000

On 2.6.0-test3 and 2.6.0-test5 the mmap() fails with EINVAL. Again, the output:

PAGE_MASK 0xfffff000, ~PAGE_MASK 0xfff
smem_start 0xcf000000 smem_len 0x400000, mmio_start 0xcffe0000, mmio_len 0x10000
fb_off 0x0 fb_len 0x400000, mmio_off 0x0, mmio_len 0x10000
mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, 3, 0x400000)
mmap mmio: Invalid argument (22)

As you see, the parameters to mmap() are identical. The problem is fb_len -
reduce this to, say, 0x3f0000 and mmap() works.

Any suggestions as to where to look next?

Jim

Test prog:

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <linux/fb.h>
#include <asm/page.h>

#define FRAMEBUFFER     "/dev/fb0"

int main(int ac, char *av[])
{
    struct fb_fix_screeninfo fix;
    int fd = open(FRAMEBUFFER, O_RDWR, 0);
    size_t mmio_len, fb_len;
    unsigned long mmio_off, fb_off;
    off_t offset;
    int prot, flags;
    void* map;

    if ( fd < 0  )
    {
        printf("Can't open " FRAMEBUFFER "\n");
        exit(1);
    }

    if ( ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0 )
        printf("IOCTL failed\n");
    else
    {
        printf("PAGE_MASK 0x%x, ~PAGE_MASK 0x%x\n", PAGE_MASK, ~PAGE_MASK);
        
        printf("smem_start 0x%x smem_len 0x%x, "
               "mmio_start 0x%x, mmio_len 0x%x\n",
               fix.smem_start, fix.smem_len, fix.mmio_start, fix.mmio_len);

        mmio_off = (unsigned long) fix.mmio_start & ~PAGE_MASK;
        mmio_len = (mmio_off + fix.mmio_len + ~PAGE_MASK) & PAGE_MASK;
        fb_off = (unsigned long) fix.smem_start & ~PAGE_MASK;
        fb_len = (fb_off + fix.smem_len + ~PAGE_MASK) & PAGE_MASK;
        
        printf("fb_off 0x%x fb_len 0x%x, "
               "mmio_off 0x%x, mmio_len 0x%x\n",
               fb_off, fb_len, mmio_off, mmio_len);

        printf("mmap(NULL, 0x%x, PROT_READ | PROT_WRITE, "
                        "MAP_SHARED, %d, 0x%x)\n",
                        mmio_len, fd, fb_len);
        map = mmap(NULL, mmio_len, PROT_READ | PROT_WRITE, MAP_SHARED,
                   fd, fb_len);
        if ( -1 == (long) map )
            printf("mmap mmio: %s (%d)\n", strerror(errno), errno);
        else
        {
            printf("Worked - map 0x%x\n", map);
            munmap(map, mmio_len);
        }
    }

    close(fd);
    exit(0);
}


-- 
Jim Hague - jim.hague@acm.org          Never trust a computer you can't lift.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help