Re: __set_origin in vga.c and screen flickering

Alan Modra (alan@spri.levels.unisa.edu.au)
Sat, 25 May 1996 19:23:23 +0930 (CST)


Paul Gortmaker <gpg109@rsphy6.anu.edu.au>
> - From Ingo Molnar (mingo@teto.sch.bme.hu)
> > If i understand it right, Linux does console scrolling by setting the
> > "origin" of the visible screen in the VGA memory. We avoid to copy the
> > whole screen with this solution. But very rarely the screen "flickers"
> > as if it got out of sync. If i remember right, the problem is the following
> > code in vga.c:
> >
> > outb_p(12, video_port_reg);
> > outb_p(offset >> 8, video_port_val);
> > outb_p(13, video_port_reg);
> > outb_p(offset, video_port_val);
> >
> > if the videocard updates the text screen just after the second or third
> > outb_p(), then the "origin" of the screen is temporarily false, and we
> > have some stray textscreen, which is a mixture of existing console
> > images. This lasts till the next screen-refresh, but it's still annoying :)
>
> True, it does look a bit clunky. You should be able to reduce the window
> of opportunity by simply changing the outb_p to simple outb calls.
Yes
> Assuming you don't have an old 8bit 256kB VGA card from 1987, it probably
> can survive without the dummy i/o cycle inserted inbetween anyway.
> Hrrm, I'll have to try this...

I've been using the following for quite a while

void
__set_origin(unsigned short offset)
{
unsigned long flags;
unsigned short high, low;

clear_selection();

high = 12 + (offset & 0xff00);
low = 13 + (offset << 8);

save_flags(flags); cli();
__origin = offset;
outw(high, video_port_reg);
outw(low, video_port_reg);
restore_flags(flags);
}