display images from SD Card

Hi,
I am using kernel sources from http://code.google.com/p/beagleboard/wiki/BeagleboardRevCValidation
Tested the audio and video playback with the uImage created and
followed the instructions given for testing. It is working fine. Video
is tested on S-Video port by connecting S-Video cable to TV.
I am interested to do some image playback from SDCard. It is like
slide show.
I need some help on this how it can be done.
Suppose if I want to display data with some color ( Green/Red/Blue)
what is the data( RGB or YUV) I have to fill
Which buffer need to be filled
what is the driver I have to use for filling the buffer
{ like s32_Id=open("/dev/xxx", O_RDWR); write
(s32_Id,u16_BufferReadPtr ,Cnt ); }
If there is any sample code to test this image play please share and
it would be great help.

I am new to BB and OMAP. Please help.

TIA

Which buffer need to be filled
what is the driver I have to use for filling the buffer
{ like s32_Id=open("/dev/xxx", O_RDWR); write
(s32_Id,u16_BufferReadPtr ,Cnt ); }

You want to read about framebuffer. For example.

If there is any sample code to test this image play please share and
it would be great help.

There are a lot of example code using framebuffer.

R.

Hi,
Could you please share me any docs & any links specific to BB ?
Could you please share me any sample/example code that worked on BB ?
It would be great help and I am thankful to you.
TIA

Hi,
I tried some sample application on framebuffer concept.
With this application http://pastebin.com/m1197c392 I could see some
display on TV via S-Video.
But in this application I am not mentioning any image format( yuv/rgb)
and display resolution.
If I see prints for it , it is having 640x480 and bpp=32 , RGB.

Can anyone tell me where I have to modify if I want to modify some
other format ( RGB 16bit, 320x240) and how to fill the buffer pointer
given by "mmap" ?

TIA

Hi,
Can anyone help me on the above mail.

Thanks for your time and concern.

Can anyone tell me where I have to modify if I want to modify some
other format ( RGB 16bit, 320x240) and how to fill the buffer pointer
given by "mmap" ?

As far as I know you cannot change the bitdepth of the framebuffer at
runtime. And also 320x240 are not possible (but with that I am
unsure). Please read the documentation of DSS2 (its somewhere in the
kerneldir). Interesting is than vinfo.bits_per_pixel of
fb_var_screeninfo. And the code is already there:

...
else { //assume 16bpp
                int b = 10;
                int g = (x-100)/6; // A little green
                int r = 31-(y-100)/16; // A lot of red
                unsigned short int t = r<<11 | g << 5 | b;
                *((unsigned short int*)(fbp + location)) = t
...

HTH.
R.

Hi ,
You mean the default values of screen Width x Height = 640x480,
format=RGB, bpp=32 ??
and can it be possible to change screen Width x Height and format ??

If we see the for loops the (x,y) indexes started from 100 and ended
at 300, how it is related to 640x480 ?
And there is some "location" logic, what is the trick on these?

I have one more doubt , what is the default screen size 640x480
represents? Is this belongs to TV resolution?
Please help me.

For easy reference I am adding the code here.
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>

int main()
{
    int fbfd = 0;
    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;
    long int screensize = 0;
    char *fbp = 0;
    int x = 0, y = 0;
    long int location = 0;

    // Open the file 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 fixed screen information
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
        printf("Error reading fixed information.\n");
        exit(2);
    }

    // Get variable screen information
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
        printf("Error reading variable information.\n");
        exit(3);
    }

    printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres,
vinfo.bits_per_pixel );

    // Figure out the size of the screen in bytes
    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

    // Map the device to memory
    fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE,
MAP_SHARED,
                       fbfd, 0);
    if ((int)fbp == -1) {
        printf("Error: failed to map framebuffer device to memory.
\n");
        exit(4);
    }
    printf("The framebuffer device was mapped to memory successfully.
\n");

    x = 100; y = 100; // Where we are going to put the pixel

    // Figure out where in memory to put the pixel
    for ( y = 100; y < 300; y++ )
        for ( x = 100; x < 300; x++ ) {

            location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
                       (y+vinfo.yoffset) * finfo.line_length;

            if ( vinfo.bits_per_pixel == 32 ) {
                *(fbp + location) = 100; // Some blue
                *(fbp + location + 1) = 15+(x-100)/2; // A little
green
                *(fbp + location + 2) = 200-(y-100)/5; // A lot of
red
                *(fbp + location + 3) = 0; // No transparency
            } else { //assume 16bpp
                int b = 10;
                int g = (x-100)/6; // A little green
                int r = 31-(y-100)/16; // A lot of red
                unsigned short int t = r<<11 | g << 5 | b;
                *((unsigned short int*)(fbp + location)) = t;
            }

        }
    munmap(fbp, screensize);
    close(fbfd);
    return 0;
}

You mean the default values of screen Width x Height = 640x480,
format=RGB, bpp=32 ??
and can it be possible to change screen Width x Height and format ??

Yes, it is possible using u-boot enviroment variables (I hope thats
their name). As I said you have to read the documentation for your
graphics driver. This is usually DSS2. You can find the documentation
for DSS2 in your kernel source.

You can check your settings with fbset.

If we see the for loops the (x,y) indexes started from 100 and ended
at 300, how it is related to 640x480 ?

Its not related, its an example. If you want to fill your whole screen
(and the screen size is 640x480) you have to loop:
for(int y=0; y<640; y++)
  for(int x=0; x<480; x++)
    ...

R.

> You mean the default values of screen Width x Height = 640x480,
> format=RGB, bpp=32 ??
> and can it be possible to change screen Width x Height and format ??

Yes, it is possible using u-boot enviroment variables (I hope thats
their name). As I said you have to read the documentation for your
graphics driver. This is usually DSS2. You can find the documentation
for DSS2 in your kernel source.

You can check your settings with fbset.

> If we see the for loops the (x,y) indexes started from 100 and ended
> at 300, how it is related to 640x480 ?

Its not related, its an example. If you want to fill your whole screen
(and the screen size is 640x480) you have to loop:
for(int y=0; y<640; y++)
for(int x=0; x<480; x++)

seems like a correction in the loop its
               for(int y=0; y<480; y++)
                           for(int x=0; x<640; x++)

Just check out whether your requirement is fulfilled by the code given
below...

tested for 640x480 RGB planar format raw image.

-------------------------------640-----------------------------------------

480
R |

-------------------------------640-----------------------------------------

480
G |

-------------------------------640-----------------------------------------

480
B |