From: Willem Kasdorp (wkasdo@paramount.nikhefk.nikhef.nl)
Date: 05/02/92


From: wkasdo@paramount.nikhefk.nikhef.nl (Willem Kasdorp)
Subject: new SVGA patch. Realtek card added
Date: 2 May 1992 19:11:06 GMT

I have a SVGA card from Realtek. Since this card is not recognized
by the startup code, I made a patch to detect it. I append it below.
Some remarks:

 - This patch is relative to Linux 0.95c+, and needs to have the
   Dennis Flaherty SVGA patch (version 3, 24th April) applied first.
   Look in tsx-11.mit.edu in the pub/linux/patches directory for this.

 - The detection is really simpleminded. I check for the string
   'REALTEK VGA' in the SVGA ROM. If there is another version of the
   REALTEK card that does not support the SVGA text modes, the patch
   needs patching :-)

 - I added an option to select the usual 80x50 VGA mode as well. Just
   press enter at the list of available text modes.

 - Someone mentioned some days ago that his machine would hang upon entering
   the SVGA selection menu. I noticed that the code in boot/setup.S directly
   reads the keyboard. That code might well hang the computer if it encounters
   some outlandish keyboard. Maybe a keyboard specialist can have a look at it.

 - If you select a SVGA text mode (not the standard 80x50 VGA mode) there is no
   login prompt at the other virtual consoles! Surely this is a bug, but is it
   mine? It is still possible to enter a login name and password though.
   Do people with other SVGA cards have it as well? Some hacking around
   in init.c and getty.c revealed no obvious reason for the bug. It is
   probably related to the fact that setting the SVGA mode clears the screen.

                regards, Willem Kasdorp (wkasdo@nikhefk.nikhef.nl)

*** boot/setup.S~ Sat May 2 20:04:41 1992
--- boot/setup.S Sat May 2 20:06:29 1992
*************** start:
*** 61,67 ****
        cmp bl,#0x10
        je novga
        call chsvga
! novga: mov [14],ax
        mov ah,#0x03 ! read cursor pos
        xor bh,bh
        int 0x10 ! save it in known place, con_init fetches
--- 61,67 ----
        cmp bl,#0x10
        je novga
        call chsvga
! novga: mov [14],ax ! store screen size
        mov ah,#0x03 ! read cursor pos
        xor bh,bh
        int 0x10 ! save it in known place, con_init fetches
*************** nokey: call getkey
*** 255,261 ****
        jb nokey
        cmp al,#0xe0
        ja nokey
! cmp al,#0x9c
        je svga
  #endif
  #if !defined(SVGA_MODE) || SVGA_MODE == VGA
--- 255,261 ----
        jb nokey
        cmp al,#0xe0
        ja nokey
! cmp al,#0x9c ! Return pressed ?
        je svga
  #endif
  #if !defined(SVGA_MODE) || SVGA_MODE == VGA
*************** even7: mov al,#0x0c
*** 470,475 ****
--- 470,489 ----
        jne novid7
        lea si,dscvideo7
        lea di,movideo7
+ lea cx,selmod
+ jmp cx
+
+ ! Added by wkasdo
+ novid7: cld ! Check Realtek 'clues'
+ lea si,idrealtek
+ mov di,#0x44
+ mov cx,#0x0b
+ repe
+ cmpsb
+ jne norealtek
+ lea si,dscrealtek
+ lea di,morealtek
+
  selmod: push si
        lea si,msg2
        call prtstr
*************** tbl: pop bx
*** 505,511 ****
--- 519,532 ----
  #if defined(SVGA_MODE) && SVGA_MODE != VGA
        mov al,#SVGA_MODE ! Preset SVGA mode
  #else
+ flush2: in al,#0x60 ! Flush the keyboard buffer
+ cmp al,#0x82
+ jb nonum
+ jmp flush2
+
  nonum: call getkey
+ cmp al,#0x9c ! Return pressed ?
+ je norealtek ! use standard vga 80x50 anyway.
        cmp al,#0x82
        jb nonum
        cmp al,cl
*************** nonum: call getkey
*** 514,531 ****
  #endif
        dec al
        xor ah,ah
! add di,ax
! inc di
        push ax
        mov al,(di)
! int 0x10
        pop ax
        shl ax,#1
! add si,ax
        lodsw
        pop ds
        ret
! novid7:
        mov ax,#0x1112
        mov bl,#0
        int 0x10 ! use 8x8 font set (50 lines on VGA)
--- 535,555 ----
  #endif
        dec al
        xor ah,ah
! add di,ax ! di points to mode table
! inc di ! skip #modes byte
        push ax
        mov al,(di)
! int 0x10 ! ah==0 -> select video mode
        pop ax
        shl ax,#1
! add si,ax ! si points to screensize table
        lodsw
        pop ds
        ret
!
! ! get here if SVGA board is not identified or not wanted. Set VGA 80x50 mode
!
! norealtek:
        mov ax,#0x1112
        mov bl,#0
        int 0x10 ! use 8x8 font set (50 lines on VGA)
*************** msg1: .ascii "Press <RETURN> to see SVG
*** 643,648 ****
--- 667,673 ----
  msg2: .ascii "Mode: COLSxROWS:"
                db 0x0d, 0x0a, 0x0a, 0x00
  msg3: .ascii "Choose mode by pressing the corresponding number."
+ .ascii " <RETURN> selects VGA 80x50."
                db 0x0d, 0x0a, 0x00
                
  idati: .ascii "761295520"
*************** idati: .ascii "761295520"
*** 649,654 ****
--- 674,680 ----
  idcandt: .byte 0xa5
  idgenoa: .byte 0x77, 0x00, 0x66, 0x99
  idparadise: .ascii "VGA="
+ idrealtek: .ascii "REALTEK VGA"
  
  ! Manufacturer: Numofmodes: Mode:
  
*************** moparadise: .byte 0x02, 0x55, 0x54
*** 662,680 ****
  motrident: .byte 0x07, 0x50, 0x51, 0x52, 0x57, 0x58, 0x59, 0x5a
  motseng: .byte 0x05, 0x26, 0x2a, 0x23, 0x24, 0x22
  movideo7: .byte 0x06, 0x40, 0x43, 0x44, 0x41, 0x42, 0x45
  
! ! msb = Cols lsb = Rows:
  
! dscati: .word 0x8419, 0x842c
! dscahead: .word 0x842c, 0x8419, 0x841c, 0xa032, 0x5042
! dsccandt: .word 0x8419, 0x8432
! dsccirrus: .word 0x8419, 0x842c, 0x841e, 0x6425
! dsceverex: .word 0x5022, 0x503c, 0x642b, 0x644b, 0x8419, 0x842c, 0x501e, 0x641b, 0xa040, 0x841e
! dscgenoa: .word 0x5020, 0x642a, 0x8419, 0x841d, 0x8420, 0x842c, 0x843c, 0x503c, 0x5042, 0x644b
! dscparadise: .word 0x8419, 0x842b
! dsctrident: .word 0x501e, 0x502b, 0x503c, 0x8419, 0x841e, 0x842b, 0x843c
! dsctseng: .word 0x503c, 0x6428, 0x8419, 0x841c, 0x842c
! dscvideo7: .word 0x502b, 0x503c, 0x643c, 0x8419, 0x842c, 0x841c
        
  .text
  endtext:
--- 688,708 ----
  motrident: .byte 0x07, 0x50, 0x51, 0x52, 0x57, 0x58, 0x59, 0x5a
  motseng: .byte 0x05, 0x26, 0x2a, 0x23, 0x24, 0x22
  movideo7: .byte 0x06, 0x40, 0x43, 0x44, 0x41, 0x42, 0x45
+ morealtek: .byte 0x07, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e
  
! ! msb = Cols lsb = Rows:
  
! dscati: .word 0x8419, 0x842c
! dscahead: .word 0x842c, 0x8419, 0x841c, 0xa032, 0x5042
! dsccandt: .word 0x8419, 0x8432
! dsccirrus: .word 0x8419, 0x842c, 0x841e, 0x6425
! dsceverex: .word 0x5022, 0x503c, 0x642b, 0x644b, 0x8419, 0x842c, 0x501e, 0x641b, 0xa040, 0x841e
! dscgenoa: .word 0x5020, 0x642a, 0x8419, 0x841d, 0x8420, 0x842c, 0x843c, 0x503c, 0x5042, 0x644b
! dscparadise: .word 0x8419, 0x842b
! dsctrident: .word 0x501e, 0x502b, 0x503c, 0x8419, 0x841e, 0x842b, 0x843c
! dsctseng: .word 0x503c, 0x6428, 0x8419, 0x841c, 0x842c
! dscvideo7: .word 0x502b, 0x503c, 0x643c, 0x8419, 0x842c, 0x841c
! dscrealtek: .word 0x501e, 0x502b, 0x503c, 0x8419, 0x841e, 0x842b, 0x843c
        
  .text
  endtext: