omapfb: help from userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've been trying to get the yuv overlay to work, but without success.
I'm trying to do what Mans Rullgard is doing on omapfbplay[1], but I
don't see anything happening.

The normal RGB plane is working fine, I'm attaching a test that writes
data to the whole framebuffer.

This is the output:
# /tmp/fb_test
main: size=720x400, 16bpp
overlay: size=720x400, 16bpp
panel: enabled=0
panel: 0x0 - 720x400
# /tmp/fb_test
main: size=720x400, 16bpp
overlay: size=720x400, 16bpp
panel: enabled=1
panel: 0x0 - 720x400

Best regards.

[1] http://git.mansr.com/?p=omapfbplay

-- 
Felipe Contreras
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <sys/mman.h>

#include <mach/omapfb.h>

#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>

#define MIN(a, b) (((a) < (b)) ? (a) : (b))

static int main_fb;
static int overlay_fb;

static struct fb_var_screeninfo main_screen_info;
static struct fb_var_screeninfo overlay_screen_info;
static struct omapfb_mem_info mem_info;
static struct omapfb_plane_info plane_info;

uint8_t *overlay_mem;

unsigned int input_width = 640;
unsigned int input_height = 480;

static void
log_helper (const char *type,
            const char *file,
            const char *function,
            unsigned int line,
            const char *fmt,
            ...)
{
    char *tmp = NULL;
    va_list args;

    va_start (args, fmt);

    vasprintf (&tmp, fmt, args);

    fprintf (stderr, "%s %s:%d:%s() %s\n",
             type,
             file, line, function,
             tmp);

    free (tmp);

    va_end (args);
}

#define log_error(...) log_helper ("error", __FILE__, __func__, __LINE__, __VA_ARGS__);

void
set_screen (void)
{
#if 0
    overlay_screen_info.xres = MIN (main_screen_info.xres, input_width) & ~15;
    overlay_screen_info.yres = MIN (main_screen_info.yres, input_height) & ~15;
    overlay_screen_info.xoffset = 0;
    overlay_screen_info.yoffset = 0;
#else
    overlay_screen_info.xres = main_screen_info.xres;
    overlay_screen_info.yres = main_screen_info.yres;
#endif
    overlay_screen_info.nonstd = OMAPFB_COLOR_YUY422;

    {
        int err;
        err = ioctl (overlay_fb, FBIOPUT_VSCREENINFO, &overlay_screen_info);
        if (err != 0)
        {
            log_error ("overlay set");
            return;
        }
    }
}

void
set_plane (void)
{
    plane_info.enabled = 1;
#if 0
    plane_info.pos_x = 0;
    plane_info.pos_y = 0;
    plane_info.out_width = main_screen_info.xres;
    plane_info.out_height = main_screen_info.yres;
#endif

    {
        int err;
        err = ioctl (overlay_fb, OMAPFB_SETUP_PLANE, &plane_info);
        if (err != 0)
        {
            log_error ("error=%i", err);
            return;
        }
    }
}

void
clean_omap (void)
{
    unsigned int i;
    for (i = 0; i < mem_info.size / 4; i++)
        ((uint32_t *) overlay_mem)[i] = 0xFFFFAAAA;
}

int
main (void)
{
    int err;
    main_fb = -1;
    overlay_fb = -1;

    main_fb = open ("/dev/fb0", O_RDWR);

    if (main_fb == -1)
    {
        log_error ("/dev/fb0");
        return 1;
    }

    if (ioctl (main_fb, FBIOGET_VSCREENINFO, &main_screen_info))
    {
        log_error ("main screen");
        goto leave;
    }

    overlay_fb = open ("/dev/fb1", O_RDWR);

    if (overlay_fb == -1)
    {
        log_error ("/dev/fb1");
        return 1;
    }

    if (ioctl (overlay_fb, FBIOGET_VSCREENINFO, &overlay_screen_info))
    {
        log_error ("overlay screen");
        goto leave;
    }

    if (ioctl (overlay_fb, OMAPFB_QUERY_PLANE, &plane_info))
    {
        log_error ("omap pane");
        goto leave;
    }

    if (ioctl (overlay_fb, OMAPFB_QUERY_MEM, &mem_info))
    {
        log_error ("omap mem");
        goto leave;
    }

    printf ("main: size=%ix%i, %ibpp\n", main_screen_info.xres, main_screen_info.yres, main_screen_info.bits_per_pixel);
    printf ("overlay: size=%ix%i, %ibpp\n", overlay_screen_info.xres, overlay_screen_info.yres, overlay_screen_info.bits_per_pixel);

    /* omap */
    printf ("panel: enabled=%u\n", plane_info.enabled);
    printf ("panel: %ux%u - %ux%u\n", plane_info.pos_x, plane_info.pos_y,
            plane_info.out_width, plane_info.out_height);

    /* map the framebuffer */
    overlay_mem = mmap (NULL, mem_info.size, PROT_WRITE, MAP_SHARED, overlay_fb, 0);
    if (overlay_mem == MAP_FAILED)
    {
        log_error ("mmap");
        goto leave;
    }

    clean_omap ();
    set_screen ();
    set_plane ();

leave:
    munmap (overlay_mem, mem_info.size);

    if (overlay_fb)
        close (overlay_fb);

    if (main_fb)
        close (main_fb);

    return 0;
}

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux