Drawing to video framebuffer in Rotated mode
James Jones
jajones at nvidia.com
Fri Oct 20 11:23:06 PDT 2006
On Friday 20 October 2006 10:07 am, Jacob Zachariah wrote:
> Hi ,
>
> I'm working with a legacy 2D application that gets the
> address of the video framebuffer (/proc/pci -
> Prefetchable memory of gfx card) & draws 2d graphics
> to it.
It is essentially luck that has allowed this to work at all, and it
will likely stop working soon. What is the application, and why
can't it use a more sane drawing method?
If you really, really, really have to insist on doing this, you're
more or less right. You might be able to get away with doing
something to trick the X driver into thinking it just updated the
region your app is drawing to. No Guarantees.
Again, please, just don't do this.
Thanks,
-James
nvpublic
> When i rotate the display using XrandR or the Nvidia
> driver's 'Rotate' methods; drawing to the framebuffer
> doesn't work as in normal mode.
>
> The example code below draws rgb bands to the
> framebuffer in normal mode.
> In rotated mode, when the program is run, I don't see
> the colors. But when i move the terminal i see the
> colors on the edges of the terminal. Tells me that
> maybe the area needs to be marked 'dirty' & the X
> server needs to copy it to the rotated buffer or
> something to that effect.
>
> What would be fast ways to accomplish this? I'm using
> Xorg6.9 on RH 7.3(2.4-18) but am curious about kdrive
> so am trying to build Xorg7.1.
>
> Tips would be much appreciated.
>
> best regards
>
> ------------------------
> #include <stdio.h>
> #include <stdlib.h>
> #include <getopt.h>
> #include <unistd.h>
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> #include <string.h>
> #include <assert.h>
>
>
>
> int main()
> {
> int val = 4096;
> // Prefetchable memory
> char ptr[16]="0xf0000000";
> unsigned long pVal = strtoul(ptr, NULL, 0);
>
> void * videoBuffer = (void *) pVal;
> int fd = open("/dev/mem", O_RDWR);
> if (fd == -1)
> {
> printf("Failed to open server memory access:
> %s\n", strerror(errno));
> exit(1);
> }
>
> void * addr = mmap(0, 0x1000000, PROT_READ |
> PROT_WRITE, MAP_SHARED, fd, (long)videoBuffer);
> if (addr == (void *) -1)
> {
> printf("Failed to mmap physical server memory:
> %s\n", strerror(errno));
> close(fd);
> exit(1);
> }
> unsigned char* pCol = (unsigned char*)addr;
>
> for(int i=0; i<100000; i++)
> {
> *pCol ++ = 255;
> *pCol ++ = 0;
> *pCol ++ = 0;
> *pCol ++ = 255;
> }
> for(int i=0; i<100000; i++)
> {
> *pCol ++ = 0;
> *pCol ++ = 255;
> *pCol ++ = 0;
> *pCol ++ = 255;
> }
> for(int i=0; i<100000; i++)
> {
> *pCol ++ = 0;
> *pCol ++ = 0;
> *pCol ++ = 255;
> *pCol ++ = 255;
> }
>
> }
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> xorg mailing list
> xorg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xorg
More information about the xorg
mailing list