* Re: Virtual framebuffer driver - mmap problem @ 2004-09-08 13:51 Shivappa Kushtagi 2004-09-09 0:31 ` Antonino A. Daplas 0 siblings, 1 reply; 4+ messages in thread From: Shivappa Kushtagi @ 2004-09-08 13:51 UTC (permalink / raw) To: linux-fbdev-devel > I would like to use virtual framebuffer on a linux system which is > installed with R.H.9 to simulate my target display ( an embedded > device with 320*480 resolution). == The virtual framebuffer is intended for testing _the kernel_ only. > I have written a application which will mmap /dev/fb0 and fill it with > some RGB values. I run framebuffer based VNC server to see whatever I > have written. I always get a white image. Looks like mmap is mapped to > some other address and fbvnc server is reading from somewhere else. > > Does the existing drivers/video/vfb.c code works ? or Do I need to > tweak it ? == You cannot mmap() the video memory of vfb. == Why don"t you use vesafb? As I had mentioned in my earlier post, I wanted to use virtual framebuffer to simulate the display of my target device (say some PDA with size 320*480 ). With vesafb, I will not be able to change the resolution ( fbset fails telling, invalid argument ) Is there any other framebuffer based methods to simulate a display ? Regards Shivappa ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: Virtual framebuffer driver - mmap problem 2004-09-08 13:51 Virtual framebuffer driver - mmap problem Shivappa Kushtagi @ 2004-09-09 0:31 ` Antonino A. Daplas 2004-09-09 8:31 ` Geert Uytterhoeven 0 siblings, 1 reply; 4+ messages in thread From: Antonino A. Daplas @ 2004-09-09 0:31 UTC (permalink / raw) To: linux-fbdev-devel, Shivappa Kushtagi On Wednesday 08 September 2004 21:51, Shivappa Kushtagi wrote: > == You cannot mmap() the video memory of vfb. > > == Why don"t you use vesafb? > > As I had mentioned in my earlier post, I wanted to use virtual > framebuffer to simulate the display of my target device (say some PDA > with size 320*480 ). With vesafb, I will not be able to change the > resolution ( fbset fails telling, invalid argument ) > > > Is there any other framebuffer based methods to simulate a display ? > There are 2 problems with vfb.c that makes mmap fail: 1. uses vmalloc to allocate framebuffer memory 2. has its own fb_mmap hook which always return -EINVAL If you want to really use vfb.c, you can try to modify vfb.c so it behaves like a normal, mmappable framebuffer. A. First you need to change the framebuffer allocation method: Do not use vmalloc, since it doesn't give you linear memory. Instead use __get_free_pages. videomemorysize = PAGE_SIZE << order; So if PAGE_SIZE is 4096, to allocate 8192 bytes, use order = 1. Note that there is an upper limit to order, so keep videomemorysize small. videomemory = __get_free_pages(GFP_KERNEL, order) B. Advertise the framebuffer to userspace: In 2.6: info->fix.smem_len = videomemorysize; info->fix.smem_start = virt_to_phys(videomemory) & PAGE_MASK; In 2.4, you can do the same, but do it in vfb_encode_fix(). C. Finally, create your own vfb_mmap() function. The important thing with this version of mmap is the use of the VM_RESERVED flag when dealing with system RAM. This flag is not necessary for actual framebuffers. You can copy the fb_mmap function in fbmem.c and modify it for vfb. For 2.6, you can use the example below. Tony static int vfb_mmap(struct fb_info *info, struct file *file, struct vm_area_struct *vma) { unsigned long off; #if !defined(__sparc__) || defined(__sparc_v9__) unsigned long start; u32 len; #endif if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) return -EINVAL; off = vma->vm_pgoff << PAGE_SHIFT; #if defined(__sparc__) && !defined(__sparc_v9__) /* Should never get here, all fb drivers should have their own mmap routines */ return -EINVAL; #else /* !sparc32... */ lock_kernel(); /* frame buffer memory */ start = info->fix.smem_start; len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.smem_len); if (off >= len) { /* memory mapped io */ off -= len; if (info->var.accel_flags) { unlock_kernel(); return -EINVAL; } start = info->fix.mmio_start; len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len); } unlock_kernel(); start &= PAGE_MASK; if ((vma->vm_end - vma->vm_start + off) > len) return -EINVAL; off += start; vma->vm_pgoff = off >> PAGE_SHIFT; /* This is an IO map - tell maydump to skip this VMA */ vma->vm_flags |= VM_IO | VM_RESERVED; #if defined(__sparc_v9__) vma->vm_flags |= (VM_SHM | VM_LOCKED); if (io_remap_page_range(vma, vma->vm_start, off, vma->vm_end - vma->vm_start, vma->vm_page_prot, 0)) return -EAGAIN; #else #if defined(__mc68000__) #if defined(CONFIG_SUN3) pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE; #elif defined(CONFIG_MMU) if (CPU_IS_020_OR_030) pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030; if (CPU_IS_040_OR_060) { pgprot_val(vma->vm_page_prot) &= _CACHEMASK040; /* Use no-cache mode, serialized */ pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S; } #endif #elif defined(__powerpc__) pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE|_PAGE_GUARDED; #elif defined(__alpha__) /* Caching is off in the I/O space quadrant by design. */ #elif defined(__i386__) || defined(__x86_64__) if (boot_cpu_data.x86 > 3) pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; #elif defined(__mips__) vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); #elif defined(__hppa__) pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE; #elif defined(__ia64__) || defined(__arm__) || defined(__sh__) vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); #else #warning What do we have to do here?? #endif if (io_remap_page_range(vma, vma->vm_start, off, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; #endif /* !__sparc_v9__ */ return 0; #endif /* !sparc32 */ } ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: Virtual framebuffer driver - mmap problem 2004-09-09 0:31 ` Antonino A. Daplas @ 2004-09-09 8:31 ` Geert Uytterhoeven 2004-09-09 10:16 ` Antonino A. Daplas 0 siblings, 1 reply; 4+ messages in thread From: Geert Uytterhoeven @ 2004-09-09 8:31 UTC (permalink / raw) To: Linux Frame Buffer Device Development; +Cc: Shivappa Kushtagi On Thu, 9 Sep 2004, Antonino A. Daplas wrote: > On Wednesday 08 September 2004 21:51, Shivappa Kushtagi wrote: > > == You cannot mmap() the video memory of vfb. > > > > == Why don"t you use vesafb? > > > > As I had mentioned in my earlier post, I wanted to use virtual > > framebuffer to simulate the display of my target device (say some PDA > > with size 320*480 ). With vesafb, I will not be able to change the > > resolution ( fbset fails telling, invalid argument ) > > > > > > Is there any other framebuffer based methods to simulate a display ? > > > > There are 2 problems with vfb.c that makes mmap fail: > > 1. uses vmalloc to allocate framebuffer memory > 2. has its own fb_mmap hook which always return -EINVAL > > If you want to really use vfb.c, you can try to modify vfb.c so it behaves > like a normal, mmappable framebuffer. > > A. First you need to change the framebuffer allocation method: Do not use > vmalloc, since it doesn't give you linear memory. Instead use > __get_free_pages. > > videomemorysize = PAGE_SIZE << order; > > So if PAGE_SIZE is 4096, to allocate 8192 bytes, use order = 1. Note that > there is an upper limit to order, so keep videomemorysize small. And the upper limit is 128 kiB on most platforms. Hence even 640x480 in 8 bpp won't fit... Probably you can make a fb_mmap() hook that's compatible with the vmalloc()'ed frame buffer and thus doesn't suffer from this limitation, but it will require more code and more knowledge of memory management internals. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Re: Virtual framebuffer driver - mmap problem 2004-09-09 8:31 ` Geert Uytterhoeven @ 2004-09-09 10:16 ` Antonino A. Daplas 0 siblings, 0 replies; 4+ messages in thread From: Antonino A. Daplas @ 2004-09-09 10:16 UTC (permalink / raw) To: linux-fbdev-devel, Geert Uytterhoeven; +Cc: Shivappa Kushtagi On Thursday 09 September 2004 16:31, Geert Uytterhoeven wrote: > > > > So if PAGE_SIZE is 4096, to allocate 8192 bytes, use order = 1. Note that > > there is an upper limit to order, so keep videomemorysize small. > > And the upper limit is 128 kiB on most platforms. Hence even 640x480 in 8 > bpp won't fit... > > Probably you can make a fb_mmap() hook that's compatible with the > vmalloc()'ed frame buffer and thus doesn't suffer from this limitation, but > it will require more code and more knowledge of memory management > internals. > Actually, I discovered that MAX_ORDER in 2.4 is 10 (4MiB) and 11 in 2.6 (8MiB), so it's probably not as limiting as it seems. However, the probability of __get_free_pages() failing at such a high order is very high. Tony ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-09-09 10:15 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-09-08 13:51 Virtual framebuffer driver - mmap problem Shivappa Kushtagi 2004-09-09 0:31 ` Antonino A. Daplas 2004-09-09 8:31 ` Geert Uytterhoeven 2004-09-09 10:16 ` Antonino A. Daplas
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).