2002-09-25 14:13:55

by Eric Miao

[permalink] [raw]
Subject: Some questions about Linux Framebuffer programming

Hi, everybody,

I need your help!

1. How can I switch to another virtual terminal by
normal user process?
VT_ACTIVATE ioctl can only be called by processes
having root rights.

2. When I switch away from and again back to the
virtual terminal where I do frame buffer drawing,
screen content is destroyed and replaced by original
console text?
How can I avoid this problem?

3. What is FBIOPUT_CON2FBMAP? What does it do?

4. How can I do flipping between primary frame and
secondary frame?





__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com


2002-09-25 14:44:07

by Burton Samograd

[permalink] [raw]
Subject: Re: Some questions about Linux Framebuffer programming

On Wed, Sep 25, 2002 at 07:19:06AM -0700, Eric Miao wrote:
>
> 1. How can I switch to another virtual terminal by
> normal user process?
> VT_ACTIVATE ioctl can only be called by processes
> having root rights.
>

This is a snippet of a little program I wrote called vtswitch that
shows how to use the VT_ACTIVATE ioctl. This works as a normal user,
so you might be using it wrong. I can send the whole program if you
want to see how the whole thing works but this is the guts:

<--- begin code block ---->

int vtfd;

#define VT_DEVICE_FILE "/dev/tty"
vtfd = open(VT_DEVICE_FILE, O_RDWR, 0);
if(vtfd < 0)
{
printf("*error* Could not open /dev/tty\n");
}

/* Save the current vt index to the history file */
save_cur_vt_index(vtfd);

/* Switch to the terminal if there wasn't an error looking up the
alias */
if(ioctl(vtfd, VT_ACTIVATE, terminal))
{
printf("*error* Error switching to terminal %s (%d)\n", vt,
terminal);
return -1;
}

<-- end code block -->


> 2. When I switch away from and again back to the
> virtual terminal where I do frame buffer drawing,
> screen content is destroyed and replaced by original
> console text?
> How can I avoid this problem?

You can save the framebuffer contents to a program array and then poll
the current vt every once and a while (using VT_GETSTATE and
vt_stat.vt_active), check to see if your program is on the visible vt
and then copy it back to restore it. This could also keep your
program from drawing to the framebuffer when it's not visible.

>
> 3. What is FBIOPUT_CON2FBMAP? What does it do?

Not sure.

>
> 4. How can I do flipping between primary frame and
> secondary frame?

Create an offscreen surface using malloc and do your rendering to that
and then do a memcpy (simple way) or hardware accellerated blt (faster
but harder to setup).

burton


Attachments:
(No filename) (1.82 kB)
(No filename) (189.00 B)
Download all attachments