hardware scaling - mmap fails?


crow_riot

Well-Known Member
Joined
Sep 21, 2009
Messages
1,763
Location
.at
I'm trying to get hardware scaling working and followed the guide from the wiki, but when i use mmap in my code, mmap fails by returning MAP_FAILED.

from my understandings, it should be enough to do the following

first in my launch script


ofbset -fb /dev/fb1 -pos 0 0 -size 800 480 -mem 384000 -en 1
fbset -fb /dev/fb1 -g 400 240 400 480 16
 
./app

part of app code


int width = 400;
int height = 240;
int bytepp = 2;
int pages = 2;
 
int fbdev = open("/dev/fb1", O_RDWR)
 
void* buffer = mmap(0, width*height*bytepp*pages, PROT_READ|PROT_WRITE, MAP_SHARED, fbdev, 0);

and afterwards i should have the pointer to the first framebuffer "page" in buffer. but all i get is MAP_FAILED.

any help is appreciated :)
 
Last edited by a moderator:
well it turns out i cannot use mmap directly here. i'm using fbdev now and it works.
 
Why can't you use it directly? It works fine for me.

You should also check errno/call perror() and also see dmesg when you get such problems.
 
just looked over your source and it seems there's in fact not much difference and also mmap is used. odd. thanks for the hints about errno / perror and so on, will have a look at that.
one question, could it be the missing
 


ioctl(fbdev->fd, FBIOBLANK, FB_BLANK_UNBLANK);

call? can't check it right now since i'm near my pandora :)
 
well thanks for your help, i just have written the few lines again and now it works. whatever went wrong 2 days ago - i will never know :)
 
I've got another question - what source dimensions are supported? is there any list?

i'm trying to add this feature to flashenv and canabalt for example has a resolution of 976x336. I'd set this values as framebuffer dimensions and let the hardware scaler scale the image down to pandora screen size. but again, i get "invalid argument" from mmap. 400x240 works for example, so i guess there are some limitations.
 
Again, 976x336 works for me, maybe you didn't allocate enough memory? Note that layer has to be hidden when you change memory allocation.

The limits are ~1/4x - 4x of output size, and width has to be divisable by 8 (or was it 16?).
 
ok works for me now too. you we're right, had forgot to adjust the memory size (feeling kinda stupid now ... but anyways ...). Have aligned to width to be a multiple of 8 and it works.

*edit*

deleted question ... :)
 
Last edited by a moderator:
Again, 976x336 works for me, maybe you didn't allocate enough memory? Note that layer has to be hidden when you change memory allocation.

The limits are ~1/4x - 4x of output size, and width has to be divisable by 8 (or was it 16?).
There are also practical limits that have to do with bandwidth/speed issues. I tried downscaling from 1600x960 (it would be useful in PIV), but it didn't work reliably. Something like 1200x720 (x1.5 in both dimensions) seems to be the practical upper limit of the input size if you want it to work on all units. And even then it may always not work with TV-out.
 
Back
Top