C2 vs N2 framebuffer

Post Reply
commando
Posts: 7
Joined: Sat Aug 26, 2017 2:23 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 0
Contact:

C2 vs N2 framebuffer

Unread post by commando » Tue Aug 27, 2019 7:31 am

I have a slideshow program that I wrote for my C2. It copies images directly into the framebuffer. I have recompiled it for my N2 running Ubuntu 18.04.3 and does not work properly. It looks like maybe the color planes are arranged differently. Can anyone give me pointers as to where to look to read about the differences in the framebuffer architecture between the C2 and N2?

Thanks

User avatar
tobetter
Posts: 3911
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 38 times
Been thanked: 155 times
Contact:

Re: C2 vs N2 framebuffer

Unread post by tobetter » Tue Aug 27, 2019 9:18 am

Can you share the screen with your app?
Which OS image are you running?
How do you write the image to the framebuffer?

commando
Posts: 7
Joined: Sat Aug 26, 2017 2:23 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 0
Contact:

Re: C2 vs N2 framebuffer

Unread post by commando » Wed Aug 28, 2019 6:18 am

$ uname -a
Linux odroidX 4.9.187-53 #1 SMP PREEMPT Fri Aug 9 06:12:18 -03 2019 aarch64 aarch64 aarch64 GNU/Linux

I open the framebuffer with

Code: Select all

void open_frame_buffer()
{
	int fbfd;
    // Open the framebuffer for reading and writing
	fbfd = open("/dev/fb0", O_RDWR);
	if (!fbfd) {
		printf("Error: cannot open framebuffer device.\n");
		exit(1);
	}
	printf("The framebuffer device was opened successfully.\n");

	    // Get variable screen information
	if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
		printf("Error reading variable information.\n");
	}
	printf("Screen size  %dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
// set up global screen values
        screenX = vinfo.xres;
        screenY = vinfo.yres;

	    // Store for reset (copy vinfo to vinfo_orig)
	memcpy(&orig_vinfo, &vinfo, sizeof(struct fb_var_screeninfo));

	    // Get fixed screen information
	if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
		printf("Error reading fixed information.\n");
	}

	    // map fb to user mem 
	screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
	fbp = (char*)mmap(0, screensize*2, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);

	if ((int)fbp == -1) {
		printf("Failed to mmap.\n");
		exit(1);
	}
}
from there I copy the raw image into the fbp location using optimized memcopy code.

The basic problem I am having is that the image once copied looks like 3-4 smaller versions of the image side by side across the screen rendered in grayscale. There is no color which makes me think that I am running into a color plane architecture issue.


Thanks

commando
Posts: 7
Joined: Sat Aug 26, 2017 2:23 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 0
Contact:

Re: C2 vs N2 framebuffer

Unread post by commando » Wed Aug 28, 2019 8:19 am

Hold the phone. It looks like the framebuffer is set for 32-bits/pixel as opposed to 24

User avatar
odroid
Site Admin
Posts: 32166
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 122 times
Been thanked: 297 times
Contact:

Re: C2 vs N2 framebuffer

Unread post by odroid » Wed Aug 28, 2019 8:51 am

You can setup struct fb_var_screeninfo and use standard ioctl with command FBIOPUT_VSCREENINFO in upper layer application.
The example code as below:

Code: Select all

    struct fb_var_screeninfo info; 
    if (ioctl(fd, FBIOGET_VSCREENINFO, &info) == -1) 
    { 
        return -errno; 
    } 

    info.reserved[0] = 0; 
    info.reserved[1] = 0; 
    info.reserved[2] = 0; 
    info.xoffset = 0; 
    info.yoffset = 0; 
    info.activate = FB_ACTIVATE_NOW; 
    info.bits_per_pixel = 32; 
    info.red.offset = 0; 
    info.red.length = 8; 
    info.green.offset = 8; 
    info.green.length = 8; 
    info.blue.offset = 16; 
    info.blue.length = 8; 
    info.transp.offset = 24; 
    info.transp.length = 0; 
    info.nonstd = 1;  
    info.yres_virtual = info.yres * NUM_BUFFERS; 
    ioctl(fd, FBIOPUT_VSCREENINFO, &info);
FYI,
info.transp.length = 0; // RGBA format need set length as 8
info.nonstd = 1; // RGBA format need set nonstd as 0


If you change transp.length from 8 to 0 and set flag nonstd to 1, you can support the following formats.

Code: Select all

COLOR_INDEX_32_BGRX
COLOR_INDEX_32_XBGR
COLOR_INDEX_32_RGBX,
COLOR_INDEX_32_XRGB
These users thanked the author odroid for the post:
commando (Wed Aug 28, 2019 11:27 pm)

commando
Posts: 7
Joined: Sat Aug 26, 2017 2:23 am
languages_spoken: english
ODROIDs: C2
Has thanked: 1 time
Been thanked: 0
Contact:

Re: C2 vs N2 framebuffer

Unread post by commando » Wed Aug 28, 2019 11:27 pm

Got it
Will give that a shot
Thanks all

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 0 guests