* save_vga question
@ 2005-09-16 15:55 Alexander E. Patrakov
2005-09-16 21:15 ` Antonino A. Daplas
0 siblings, 1 reply; 2+ messages in thread
From: Alexander E. Patrakov @ 2005-09-16 15:55 UTC (permalink / raw)
To: Linux Fbdev development list
Hello,
I am currently developing a framebuffer driver for S3 Trio 3D/2X cards.
Well, I have a working non-accelerated driver and I am going to submit
it later, but serious code cleanup is needed now.
I see that other fb drivers save the card state on the first open and
restore it when the open count reaches zero. I also implemented this,
but certainly not in the best way: by writing custom functions that save
all CRTC, Sequencer, Graphics and Attribute VGA-like registers. I think
that using vga_save is better here (because it also saves e.g. fonts),
but there is a problem. Some registers of the card lock/unlock other
registers. So the code in my custom save function looks like this (e.g.
for Sequencer registers):
static void save_state(struct s3d2xfb_par * par)
{
/* ... */
u8 sr08;
/* ... */
sr08 = readSR(par, 0x08);
writeSR(par, 0x06, 0x08); /* Unlock SR10-15, otherwise they are
unreadable */
for (i=0; i<sizeof(par->saved_SR); i++)
par->saved_SR[i] = readSR(par, i);
par->saved_SR[0x08] = sr08;
writeSR(par, sr08, 0x08);
/* ... */
}
and the corresponding code in the restore function:
static void restore_state(struct fb_info *info)
{
int i;
struct s3d2xfb_par *par = (struct s3d2xfb_par *) info->par;
s3d2xfb_unlock_regs(info); /* includes a writeSR(par, sr08, 0x08); */
/* ... */
for (i=0; i<sizeof(par->saved_SR); i++)
if (i!=0x08)
writeSR(par, par->saved_SR[i], i);
/* ... */
writeSR(par, par->saved_SR[0x08], 0x08);
/* ... */
}
What's the recommended way of using the save_vga() function when such
locking problems exist? Is it acceptable to manually save the state
necessary to restore locking (SR08 in the example above), unlock
everything, and then save the "unlocked" state with vga_save?
--
Alexander E. Patrakov
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: save_vga question
2005-09-16 15:55 save_vga question Alexander E. Patrakov
@ 2005-09-16 21:15 ` Antonino A. Daplas
0 siblings, 0 replies; 2+ messages in thread
From: Antonino A. Daplas @ 2005-09-16 21:15 UTC (permalink / raw)
To: linux-fbdev-devel; +Cc: Alexander E. Patrakov
Alexander E. Patrakov wrote:
> Hello,
>
> I am currently developing a framebuffer driver for S3 Trio 3D/2X cards.
> Well, I have a working non-accelerated driver and I am going to submit
> it later, but serious code cleanup is needed now.
>
> I see that other fb drivers save the card state on the first open and
> restore it when the open count reaches zero. I also implemented this,
> but certainly not in the best way: by writing custom functions that save
> all CRTC, Sequencer, Graphics and Attribute VGA-like registers. I think
> that using vga_save is better here (because it also saves e.g. fonts),
> but there is a problem. Some registers of the card lock/unlock other
> registers. So the code in my custom save function looks like this (e.g.
> for Sequencer registers):
>
> static void save_state(struct s3d2xfb_par * par)
> {
> /* ... */
> u8 sr08;
> /* ... */
> sr08 = readSR(par, 0x08);
> writeSR(par, 0x06, 0x08); /* Unlock SR10-15, otherwise they are
> unreadable */
> for (i=0; i<sizeof(par->saved_SR); i++)
> par->saved_SR[i] = readSR(par, i);
> par->saved_SR[0x08] = sr08;
> writeSR(par, sr08, 0x08);
> /* ... */
> }
>
> and the corresponding code in the restore function:
>
> static void restore_state(struct fb_info *info)
> {
> int i;
> struct s3d2xfb_par *par = (struct s3d2xfb_par *) info->par;
> s3d2xfb_unlock_regs(info); /* includes a writeSR(par, sr08, 0x08); */
> /* ... */
> for (i=0; i<sizeof(par->saved_SR); i++)
> if (i!=0x08)
> writeSR(par, par->saved_SR[i], i);
> /* ... */
> writeSR(par, par->saved_SR[0x08], 0x08);
> /* ... */
> }
>
> What's the recommended way of using the save_vga() function when such
> locking problems exist? Is it acceptable to manually save the state
> necessary to restore locking (SR08 in the example above), unlock
> everything, and then save the "unlocked" state with vga_save?
>
save_vga will only save/restore standard VGA registers, ie, in the case of the
sequencers, SR00 - SR04. Any registers above those are extended VGA
registers, ie, their purpose depend from hardware to hardware.
So you can do it 2 ways: One, you can save all standard VGA registers using
save_vga and save the extended VGA registers using your own function, unlocking
the locked registers, if necessary.
Another way is to set state->num_seq = 16, unlock all locked registers, then
call save_vga.
I prefer doing the first, but it's up to you. In both case, I think it's
important to save the registers in their "unlocked" state.
Tony
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-09-16 21:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-16 15:55 save_vga question Alexander E. Patrakov
2005-09-16 21:15 ` 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).