ia64/xen-unstable

changeset 11137:d853acd5ed58

Clean up vga.c and change default font slot to zero, as other
slots are not supported by ATI video cards.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Aug 15 11:36:10 2006 +0100 (2006-08-15)
parents 01a4266e4dc9
children 60eacb336e35 aff2e2b7a23b
files xen/drivers/video/vga.c xen/include/xen/vga.h
line diff
     1.1 --- a/xen/drivers/video/vga.c	Tue Aug 15 11:17:36 2006 +0100
     1.2 +++ b/xen/drivers/video/vga.c	Tue Aug 15 11:36:10 2006 +0100
     1.3 @@ -170,59 +170,59 @@
     1.4   * generic VGA port read/write
     1.5   */
     1.6   
     1.7 -static inline uint8_t vga_io_r (uint16_t port)
     1.8 +static inline uint8_t vga_io_r(uint16_t port)
     1.9  {
    1.10      return inb(port);
    1.11  }
    1.12  
    1.13 -static inline void vga_io_w (uint16_t port, uint8_t val)
    1.14 +static inline void vga_io_w(uint16_t port, uint8_t val)
    1.15  {
    1.16      outb(val, port);
    1.17  }
    1.18  
    1.19 -static inline void vga_io_w_fast (uint16_t port, uint8_t reg, uint8_t val)
    1.20 +static inline void vga_io_w_fast(uint16_t port, uint8_t reg, uint8_t val)
    1.21  {
    1.22 -    outw(VGA_OUT16VAL (val, reg), port);
    1.23 +    outw(VGA_OUT16VAL(val, reg), port);
    1.24  }
    1.25  
    1.26 -static inline uint8_t vga_mm_r (void __iomem *regbase, uint16_t port)
    1.27 +static inline uint8_t vga_mm_r(void __iomem *regbase, uint16_t port)
    1.28  {
    1.29 -    return readb (regbase + port);
    1.30 +    return readb(regbase + port);
    1.31  }
    1.32  
    1.33 -static inline void vga_mm_w (void __iomem *regbase, uint16_t port, uint8_t val)
    1.34 +static inline void vga_mm_w(void __iomem *regbase, uint16_t port, uint8_t val)
    1.35  {
    1.36 -    writeb (val, regbase + port);
    1.37 +    writeb(val, regbase + port);
    1.38  }
    1.39  
    1.40 -static inline void vga_mm_w_fast (void __iomem *regbase, uint16_t port, uint8_t reg, uint8_t val)
    1.41 +static inline void vga_mm_w_fast(void __iomem *regbase, uint16_t port, uint8_t reg, uint8_t val)
    1.42  {
    1.43 -    writew (VGA_OUT16VAL (val, reg), regbase + port);
    1.44 +    writew(VGA_OUT16VAL(val, reg), regbase + port);
    1.45  }
    1.46  
    1.47 -static inline uint8_t vga_r (void __iomem *regbase, uint16_t port)
    1.48 +static inline uint8_t vga_r(void __iomem *regbase, uint16_t port)
    1.49  {
    1.50      if (regbase)
    1.51 -        return vga_mm_r (regbase, port);
    1.52 +        return vga_mm_r(regbase, port);
    1.53      else
    1.54 -        return vga_io_r (port);
    1.55 +        return vga_io_r(port);
    1.56  }
    1.57  
    1.58 -static inline void vga_w (void __iomem *regbase, uint16_t port, uint8_t val)
    1.59 +static inline void vga_w(void __iomem *regbase, uint16_t port, uint8_t val)
    1.60  {
    1.61      if (regbase)
    1.62 -        vga_mm_w (regbase, port, val);
    1.63 +        vga_mm_w(regbase, port, val);
    1.64      else
    1.65 -        vga_io_w (port, val);
    1.66 +        vga_io_w(port, val);
    1.67  }
    1.68  
    1.69  
    1.70 -static inline void vga_w_fast (void __iomem *regbase, uint16_t port, uint8_t reg, uint8_t val)
    1.71 +static inline void vga_w_fast(void __iomem *regbase, uint16_t port, uint8_t reg, uint8_t val)
    1.72  {
    1.73      if (regbase)
    1.74 -        vga_mm_w_fast (regbase, port, reg, val);
    1.75 +        vga_mm_w_fast(regbase, port, reg, val);
    1.76      else
    1.77 -        vga_io_w_fast (port, reg, val);
    1.78 +        vga_io_w_fast(port, reg, val);
    1.79  }
    1.80  
    1.81  
    1.82 @@ -230,19 +230,19 @@ static inline void vga_w_fast (void __io
    1.83   * VGA CRTC register read/write
    1.84   */
    1.85   
    1.86 -static inline uint8_t vga_rcrt (void __iomem *regbase, uint8_t reg)
    1.87 +static inline uint8_t vga_rcrt(void __iomem *regbase, uint8_t reg)
    1.88  {
    1.89 -    vga_w (regbase, VGA_CRT_IC, reg);
    1.90 -    return vga_r (regbase, VGA_CRT_DC);
    1.91 +    vga_w(regbase, VGA_CRT_IC, reg);
    1.92 +    return vga_r(regbase, VGA_CRT_DC);
    1.93  }
    1.94  
    1.95 -static inline void vga_wcrt (void __iomem *regbase, uint8_t reg, uint8_t val)
    1.96 +static inline void vga_wcrt(void __iomem *regbase, uint8_t reg, uint8_t val)
    1.97  {
    1.98  #ifdef VGA_OUTW_WRITE
    1.99 -    vga_w_fast (regbase, VGA_CRT_IC, reg, val);
   1.100 +    vga_w_fast(regbase, VGA_CRT_IC, reg, val);
   1.101  #else
   1.102 -    vga_w (regbase, VGA_CRT_IC, reg);
   1.103 -    vga_w (regbase, VGA_CRT_DC, val);
   1.104 +    vga_w(regbase, VGA_CRT_IC, reg);
   1.105 +    vga_w(regbase, VGA_CRT_DC, val);
   1.106  #endif /* VGA_OUTW_WRITE */
   1.107  }
   1.108  
   1.109 @@ -250,19 +250,19 @@ static inline void vga_wcrt (void __iome
   1.110   * VGA sequencer register read/write
   1.111   */
   1.112   
   1.113 -static inline uint8_t vga_rseq (void __iomem *regbase, uint8_t reg)
   1.114 +static inline uint8_t vga_rseq(void __iomem *regbase, uint8_t reg)
   1.115  {
   1.116 -    vga_w (regbase, VGA_SEQ_I, reg);
   1.117 -    return vga_r (regbase, VGA_SEQ_D);
   1.118 +    vga_w(regbase, VGA_SEQ_I, reg);
   1.119 +    return vga_r(regbase, VGA_SEQ_D);
   1.120  }
   1.121  
   1.122 -static inline void vga_wseq (void __iomem *regbase, uint8_t reg, uint8_t val)
   1.123 +static inline void vga_wseq(void __iomem *regbase, uint8_t reg, uint8_t val)
   1.124  {
   1.125  #ifdef VGA_OUTW_WRITE
   1.126 -    vga_w_fast (regbase, VGA_SEQ_I, reg, val);
   1.127 +    vga_w_fast(regbase, VGA_SEQ_I, reg, val);
   1.128  #else
   1.129 -    vga_w (regbase, VGA_SEQ_I, reg);
   1.130 -    vga_w (regbase, VGA_SEQ_D, val);
   1.131 +    vga_w(regbase, VGA_SEQ_I, reg);
   1.132 +    vga_w(regbase, VGA_SEQ_D, val);
   1.133  #endif /* VGA_OUTW_WRITE */
   1.134  }
   1.135  
   1.136 @@ -270,19 +270,19 @@ static inline void vga_wseq (void __iome
   1.137   * VGA graphics controller register read/write
   1.138   */
   1.139   
   1.140 -static inline uint8_t vga_rgfx (void __iomem *regbase, uint8_t reg)
   1.141 +static inline uint8_t vga_rgfx(void __iomem *regbase, uint8_t reg)
   1.142  {
   1.143 -    vga_w (regbase, VGA_GFX_I, reg);
   1.144 -    return vga_r (regbase, VGA_GFX_D);
   1.145 +    vga_w(regbase, VGA_GFX_I, reg);
   1.146 +    return vga_r(regbase, VGA_GFX_D);
   1.147  }
   1.148  
   1.149 -static inline void vga_wgfx (void __iomem *regbase, uint8_t reg, uint8_t val)
   1.150 +static inline void vga_wgfx(void __iomem *regbase, uint8_t reg, uint8_t val)
   1.151  {
   1.152  #ifdef VGA_OUTW_WRITE
   1.153 -    vga_w_fast (regbase, VGA_GFX_I, reg, val);
   1.154 +    vga_w_fast(regbase, VGA_GFX_I, reg, val);
   1.155  #else
   1.156 -    vga_w (regbase, VGA_GFX_I, reg);
   1.157 -    vga_w (regbase, VGA_GFX_D, val);
   1.158 +    vga_w(regbase, VGA_GFX_I, reg);
   1.159 +    vga_w(regbase, VGA_GFX_D, val);
   1.160  #endif /* VGA_OUTW_WRITE */
   1.161  }
   1.162  
   1.163 @@ -290,16 +290,16 @@ static inline void vga_wgfx (void __iome
   1.164   * VGA attribute controller register read/write
   1.165   */
   1.166   
   1.167 -static inline uint8_t vga_rattr (void __iomem *regbase, uint8_t reg)
   1.168 +static inline uint8_t vga_rattr(void __iomem *regbase, uint8_t reg)
   1.169  {
   1.170 -    vga_w (regbase, VGA_ATT_IW, reg);
   1.171 -    return vga_r (regbase, VGA_ATT_R);
   1.172 +    vga_w(regbase, VGA_ATT_IW, reg);
   1.173 +    return vga_r(regbase, VGA_ATT_R);
   1.174  }
   1.175  
   1.176 -static inline void vga_wattr (void __iomem *regbase, uint8_t reg, uint8_t val)
   1.177 +static inline void vga_wattr(void __iomem *regbase, uint8_t reg, uint8_t val)
   1.178  {
   1.179 -    vga_w (regbase, VGA_ATT_IW, reg);
   1.180 -    vga_w (regbase, VGA_ATT_W, val);
   1.181 +    vga_w(regbase, VGA_ATT_IW, reg);
   1.182 +    vga_w(regbase, VGA_ATT_W, val);
   1.183  }
   1.184  
   1.185  static int detect_video(void *video_base)
   1.186 @@ -324,7 +324,7 @@ static int detect_video(void *video_base
   1.187      return video_found;
   1.188  }
   1.189  
   1.190 -int detect_vga()
   1.191 +static int detect_vga(void)
   1.192  {
   1.193      /*
   1.194       * Look at a number of well-known locations. Even if video is not at
   1.195 @@ -341,7 +341,7 @@ int detect_vga()
   1.196  }
   1.197  
   1.198  /* This is actually code from vgaHWRestore in an old version of XFree86 :-) */
   1.199 -void *setup_vga()
   1.200 +void *setup_vga(void)
   1.201  {
   1.202      /* The following VGA state was saved from a chip in text mode 3. */
   1.203      static unsigned char regs[] = {
   1.204 @@ -464,10 +464,13 @@ static int vga_set_scanlines(unsigned sc
   1.205  #define FONT_HEIGHT_MAX 32
   1.206  #define CHAR_MAP_SIZE (FONT_COUNT_MAX * FONT_HEIGHT_MAX)
   1.207  
   1.208 -/* At least on various ATI cards I haven't been able to get the sequencer
   1.209 -   to honor the change to the character map select register, thus at least
   1.210 -   a way to override the slot is needed. */
   1.211 -static unsigned font_slot = 2;
   1.212 +/*
   1.213 + * We use font slot 0 because ATI cards do not honour changes to the
   1.214 + * character map select register. The fontslot parameter can be used to
   1.215 + * choose a non-default slot if the video card supports it and you wish to
   1.216 + * preserve the BIOS-initialised font data.
   1.217 + */
   1.218 +static unsigned font_slot = 0;
   1.219  integer_param("fontslot", font_slot);
   1.220  
   1.221  int vga_load_font(const struct font_desc *font, unsigned rows)
   1.222 @@ -508,15 +511,18 @@ int vga_load_font(const struct font_desc
   1.223      /* map start at A000:0000 */
   1.224      vga_wgfx(vgabase, VGA_GFX_MISC, 0x00);
   1.225  
   1.226 -    if (font) {
   1.227 +    if ( font )
   1.228 +    {
   1.229          unsigned i, j;
   1.230          const uint8_t *data = font->data;
   1.231 -        uint8_t *map = (uint8_t *)__va(0xA0000) + font_slot * 2 * CHAR_MAP_SIZE;
   1.232 +        uint8_t *map = (uint8_t *)__va(0xA0000) + font_slot*2*CHAR_MAP_SIZE;
   1.233  
   1.234 -        for (i = j = 0; i < CHAR_MAP_SIZE; ) {
   1.235 -            vga_writeb(j < font->count * fontheight ? data[j++] : 0, map + i++);
   1.236 -            if (!(j % fontheight))
   1.237 -                while(i & (FONT_HEIGHT_MAX - 1))
   1.238 +        for ( i = j = 0; i < CHAR_MAP_SIZE; )
   1.239 +        {
   1.240 +            vga_writeb(j < font->count * fontheight ? data[j++] : 0,
   1.241 +                       map + i++);
   1.242 +            if ( !(j % fontheight) )
   1.243 +                while ( i & (FONT_HEIGHT_MAX - 1) )
   1.244                      vga_writeb(0, map + i++);
   1.245          }
   1.246      }
   1.247 @@ -527,9 +533,9 @@ int vga_load_font(const struct font_desc
   1.248      vga_wseq(vgabase, VGA_SEQ_PLANE_WRITE, 0x03);
   1.249      /* odd-even addressing */
   1.250      vga_wseq(vgabase, VGA_SEQ_MEMORY_MODE, 0x03);
   1.251 -    /* Character Map Select: The default font is kept in slot 0 and
   1.252 -     * is never touched. Our custom font is loaded in slot 2. */
   1.253 -    vga_wseq(vgabase, VGA_SEQ_CHARACTER_MAP, font ? font_slot | (font_slot << 2) : 0x00);
   1.254 +    /* Character Map Select: The default font is kept in slot 0. */
   1.255 +    vga_wseq(vgabase, VGA_SEQ_CHARACTER_MAP,
   1.256 +             font ? font_slot | (font_slot << 2) : 0x00);
   1.257      /* clear synchronous reset */
   1.258      vga_wseq(vgabase, VGA_SEQ_RESET, 0x03);
   1.259  
   1.260 @@ -545,9 +551,11 @@ int vga_load_font(const struct font_desc
   1.261      vga_wcrt(vgabase, VGA_CRTC_MAX_SCAN, fsr);
   1.262  
   1.263      /* Cursor shape registers */
   1.264 -    fsr = (vga_rcrt(vgabase, VGA_CRTC_CURSOR_END) & 0xe0) | (fontheight - fontheight / 6);
   1.265 +    fsr  = vga_rcrt(vgabase, VGA_CRTC_CURSOR_END) & 0xe0;
   1.266 +    fsr |= fontheight - fontheight / 6;
   1.267      vga_wcrt(vgabase, VGA_CRTC_CURSOR_END, fsr);
   1.268 -    fsr = (vga_rcrt(vgabase, VGA_CRTC_CURSOR_START) & 0xe0) | ((fsr & 0x1f) - 1);
   1.269 +    fsr  = vga_rcrt(vgabase, VGA_CRTC_CURSOR_START) & 0xe0;
   1.270 +    fsr |= (fsr & 0x1f) - 1;
   1.271      vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, fsr);
   1.272  
   1.273      return 0;
     2.1 --- a/xen/include/xen/vga.h	Tue Aug 15 11:17:36 2006 +0100
     2.2 +++ b/xen/include/xen/vga.h	Tue Aug 15 11:36:10 2006 +0100
     2.3 @@ -11,7 +11,6 @@
     2.4  
     2.5  struct font_desc;
     2.6  
     2.7 -int detect_vga(void);
     2.8  void *setup_vga(void);
     2.9  void vga_cursor_off(void);
    2.10  int vga_load_font(const struct font_desc *, unsigned rows);