linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to use ISRAm as a frame buffer in Linux
@ 2006-05-30  9:32 Prakhar Vig
  2006-05-30 12:33 ` Antonino A. Daplas
  0 siblings, 1 reply; 6+ messages in thread
From: Prakhar Vig @ 2006-05-30  9:32 UTC (permalink / raw)
  To: linux-fbdev-devel

[-- Attachment #1: Type: text/plain, Size: 563 bytes --]

 Hi All,

I would like to read a Image data already present in the framebuffer, as I
am new to this , I am finding it difficult to read. I have written one small
application where I want to read Image pixels value which are present in
Frame buffer.

I am working on linux and also want to use ISRAM as a frame buffer, but
finding it difficult to use it.

Please help me out, if some one know something in this regard. I will highly
appreciate if someone can provide me code snippet for the same. As this will
clear my lots of doubts.

Thanks And Regards
 Prakhar

[-- Attachment #2: Type: text/html, Size: 767 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use ISRAm as a frame buffer in Linux
  2006-05-30  9:32 How to use ISRAm as a frame buffer in Linux Prakhar Vig
@ 2006-05-30 12:33 ` Antonino A. Daplas
  2006-05-31  4:43   ` Prakhar Vig
  0 siblings, 1 reply; 6+ messages in thread
From: Antonino A. Daplas @ 2006-05-30 12:33 UTC (permalink / raw)
  To: linux-fbdev-devel; +Cc: prakharv

Prakhar Vig wrote:
> Hi All,
>  
> I would like to read a Image data already present in the framebuffer, as
> I am new to this , I am finding it difficult to read. I have written one
> small application where I want to read Image pixels value which are
> present in Frame buffer.
>  

You can simply open and read /dev/fb0 and it will dump the framebuffer
in raw format.

cat /dev/fb0 will also do the trick.

Google for a screenshot program for the framebuffer. fbgrab is an example.

Tony


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use ISRAm as a frame buffer in Linux
  2006-05-30 12:33 ` Antonino A. Daplas
@ 2006-05-31  4:43   ` Prakhar Vig
  2006-05-31  4:49     ` Antonino A. Daplas
  0 siblings, 1 reply; 6+ messages in thread
From: Prakhar Vig @ 2006-05-31  4:43 UTC (permalink / raw)
  To: Antonino A. Daplas; +Cc: linux-fbdev-devel

[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]

Hi Antonino,

I tried reading the data from framebuffer using cat as u have told, I wrote
the following command:

cat /dev/fb0 > image.txt

Is the command correct or not, as I am getting some corrupted data......
Below is the some part of data, which I am getting:

W<8d>õ<8c>^U<8d>Ã<8c><8c>c<86>2^D"Ã(c)^Yí2Ã*uC[\<9c>dÃ^\m^\u]u|}\}}}<9d><85>^?<8^?<85>¿<8d>Ã<8d>þ<95>Ã<95>ý<95>ý<95>ÿ<9d>ÿ<9d>^_<9e>^_<9e>^_<9e>?<9e>><9e>9d><98>Â¥p

And could you please tell me how to get the RGB data from framebuffer.

Thanks And Regards
Prakhar



On 5/30/06, Antonino A. Daplas <adaplas@gmail.com> wrote:
>
> Prakhar Vig wrote:
> > Hi All,
> >
> > I would like to read a Image data already present in the framebuffer, as
> > I am new to this , I am finding it difficult to read. I have written one
> > small application where I want to read Image pixels value which are
> > present in Frame buffer.
> >
>
> You can simply open and read /dev/fb0 and it will dump the framebuffer
> in raw format.
>
> cat /dev/fb0 will also do the trick.
>
> Google for a screenshot program for the framebuffer. fbgrab is an example.
>
> Tony
>

[-- Attachment #2: Type: text/html, Size: 1813 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use ISRAm as a frame buffer in Linux
  2006-05-31  4:43   ` Prakhar Vig
@ 2006-05-31  4:49     ` Antonino A. Daplas
  2006-05-31  9:40       ` Prakhar Vig
  0 siblings, 1 reply; 6+ messages in thread
From: Antonino A. Daplas @ 2006-05-31  4:49 UTC (permalink / raw)
  To: Prakhar Vig; +Cc: linux-fbdev-devel

Prakhar Vig wrote:
> Hi Antonino,
>  
> I tried reading the data from framebuffer using cat as u have told, I
> wrote the following command:
>  
> cat /dev/fb0 > image.txt
>  
> Is the command correct or not, as I am getting some corrupted data......
> Below is the some part of data, which I am getting:
>  
> W<8d>õ<8c>^U<8d>Ã<8c><8c>c<86>2^D"é^Yí2Ã*uC[\<9c>dÃ^\m^\u]u|}\}}}<9d><85>^?<8^?<85>¿<8d>Ã<8d>þ<95>Ã<95>ý<95>ý<95>ÿ<9d>ÿ<9d>^_<9e>^_<9e>^_<9e>?<9e>><9e>9d><98>Â¥p
> 
>  
> And could you please tell me how to get the RGB data from framebuffer.
>  

What you get is raw framebuffer format.  If you 'cat image.txt > /dev/fb0',
you'll get the same image you dumped previously. 

In order for it to be read by an image viewer, you have to convert it
into a standard format.

Try searching for fbshot or fbgrab and look at the source.

Tony


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use ISRAm as a frame buffer in Linux
  2006-05-31  4:49     ` Antonino A. Daplas
@ 2006-05-31  9:40       ` Prakhar Vig
  2006-05-31 11:39         ` Antonino A. Daplas
  0 siblings, 1 reply; 6+ messages in thread
From: Prakhar Vig @ 2006-05-31  9:40 UTC (permalink / raw)
  To: Antonino A. Daplas; +Cc: linux-fbdev-devel


[-- Attachment #1.1: Type: text/plain, Size: 1894 bytes --]

Hi Antonino,
thanks for ur help.

As u have told I am using an application that reads a data from framebuffer
by opening /dev/fb0. I am attaching the code for ur convineance, I would
like to ask following questions:

1) In this code I am using mmap to allocate memory to frame buffer which has
one argument
MAP_SHARED or MAP_PRIVATE. Could you please explain for what this meant for
i.e whether it ie related to allocation in SDRAM or ISRAM. MAP_SHARED in
SDRAM and MAP_PRIVATE in ISRAM is it so.

2) If not, Could you please tell me how to allocate framebuffer to ISRAM as
is faster to access from ISRAM than SDRAM.

3) Also, tell me whether I need to use DMA to access data from ISRAM, will
it improve the speed of accessing the data from ISRAM. Is it mandatory to
use DMA if you want to make it work fast.

Once again thanks for yr earnest help.

Thanks And Regards
Prakhar



On 5/31/06, Antonino A. Daplas <adaplas@gmail.com> wrote:
>
> Prakhar Vig wrote:
> > Hi Antonino,
> >
> > I tried reading the data from framebuffer using cat as u have told, I
> > wrote the following command:
> >
> > cat /dev/fb0 > image.txt
> >
> > Is the command correct or not, as I am getting some corrupted data......
> > Below is the some part of data, which I am getting:
> >
> >
> W<8d>õ<8c>^U<8d>Ã<8c><8c>c<86>2^D"Ã(c)^Yí2Ã*uC[\<9c>dÃ^\m^\u]u|}\}}}<9d><85>^?<8^?<85>¿<8d>Ã<8d>þ<95>Ã<95>ý<95>ý<95>ÿ<9d>ÿ<9d>^_<9e>^_<9e>^_<9e>?<9e>><9e>9d><98>Â¥p
> >
> >
> > And could you please tell me how to get the RGB data from framebuffer.
> >
>
> What you get is raw framebuffer format.  If you 'cat image.txt >
> /dev/fb0',
> you'll get the same image you dumped previously.
>
> In order for it to be read by an image viewer, you have to convert it
> into a standard format.
>
> Try searching for fbshot or fbgrab and look at the source.
>
> Tony
>

[-- Attachment #1.2: Type: text/html, Size: 2611 bytes --]

[-- Attachment #2: testfb.c --]
[-- Type: text/plain, Size: 2034 bytes --]

    #include <linux/fb.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
# include<sys/ioctl.h>
# include<sys/time.h>
# include <fcntl.h>
# include<unistd.h>
#include <sys/stat.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;
        int i;
	unsigned short int t;
	




        // 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;
	printf("\n screen size is %ld",screensize);	
	
        // 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");

 
		
	i=0;
	 for (y = 0; y < 1; y++)
            for (x = 0; x < 8; x++)
		{
		  t=*((unsigned short int*)(fbp +i)) ;
		 i++;	
		}

	printf("\n after loop");
        munmap(fbp, screensize);
        close(fbfd);
        return 0;
    }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to use ISRAm as a frame buffer in Linux
  2006-05-31  9:40       ` Prakhar Vig
@ 2006-05-31 11:39         ` Antonino A. Daplas
  0 siblings, 0 replies; 6+ messages in thread
From: Antonino A. Daplas @ 2006-05-31 11:39 UTC (permalink / raw)
  To: Prakhar Vig; +Cc: linux-fbdev-devel

Prakhar Vig wrote:
> Hi Antonino,
> thanks for ur help.
>  
> As u have told I am using an application that reads a data from
> framebuffer by opening /dev/fb0. I am attaching the code for ur
> convineance, I would like to ask following questions:
>  
> 1) In this code I am using mmap to allocate memory to frame buffer which
> has one argument
> MAP_SHARED or MAP_PRIVATE.

If you use MAP_PRIVATE, it will create a map using copy-on-write which
is visible only to the process the requested the mmap.  You don't want
this, use MAP_PRIVATE.
 
> Could you please explain for what this meant
> for i.e whether it ie related to allocation in SDRAM or ISRAM.
> MAP_SHARED in SDRAM and MAP_PRIVATE in ISRAM is it so.
>  
> 2) If not, Could you please tell me how to allocate framebuffer to ISRAM
> as is faster to access from ISRAM than SDRAM.

I don't know. Is this memory visible to the CPU? If it is then it
is certainly mappable. If not, then you have to allocate a shadow
buffer using system RAM, then on intervals, transfer the contents of
the shadow buffer to and from this memory region using DMA.

>  
> 3) Also, tell me whether I need to use DMA to access data from ISRAM,
> will it improve the speed of accessing the data from ISRAM. Is it
> mandatory to use DMA if you want to make it work fast.

You cannot use DMA when your method of access is mmap. You can certainly
use DMA to transfer contents to a shadow buffer which is in turn mmapped.

Tony  


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-31 11:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-30  9:32 How to use ISRAm as a frame buffer in Linux Prakhar Vig
2006-05-30 12:33 ` Antonino A. Daplas
2006-05-31  4:43   ` Prakhar Vig
2006-05-31  4:49     ` Antonino A. Daplas
2006-05-31  9:40       ` Prakhar Vig
2006-05-31 11:39         ` Antonino A. Daplas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).