Can not set proper Framebuffer settings

I don’t know is this problem pure OS or Hardware related, but since the board I have is BBB, I think I will try to get some help here.
My BBB is A5C version and my Linux distribution is stock Angstrom v2012.12.

The problem is I can’t set proper framebuffer settings in my C application.
I open the /dev/fb0, then I get the fixed and variable screnn info by ioctls (FBIOGET_FSCREENINFO and FBIOGET_VSCREENINFO).

After these calls I can read that:
fb_fix_screeninfo.smem_len = 2621440
fb_fix_screeninfo.line_length = 2560

My target resolution is 1280x1024, but I want to use double buffering, so xres_virtual should be 2560.
The color depth is going to be 8bit.

So I calculate if I can use these parameters.
2560 * 1024 * (8/8) = 2621440 which is equal to FB memory, so I think it should work fine.

My code is:

vinfo.bits_per_pixel = 8;
vinfo.xres = 1280;
vinfo.yres = 1024;
vinfo.xres_virtual = 2560;
vinfo.yres_virtual = 1024;
if (ioctl(fb, FBIOPUT_VSCREENINFO, &vinfo))
printf(“Error setting variable information. %d\n”, errno);
return 1;

This ioctl results in error and errno is set to 22 (Invalid argument).

What am I doing wrong here?