The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/pc/vgamga2164w.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include "u.h"
    2 #include "../port/lib.h"
    3 #include "mem.h"
    4 #include "dat.h"
    5 #include "fns.h"
    6 #include "io.h"
    7 #include "../port/error.h"
    8 
    9 #define Image   IMAGE
   10 #include <draw.h>
   11 #include <memdraw.h>
   12 #include <cursor.h>
   13 #include "screen.h"
   14 
   15 /*
   16  * Matrox Millennium and Matrox Millennium II.
   17  * Matrox MGA-2064W, MGA-2164W 3D graphics accelerators.
   18  * Texas Instruments Tvp3026 RAMDAC.
   19  */
   20 
   21 enum {
   22         /* pci chip manufacturer */
   23         MATROX          = 0x102B,
   24 
   25         /* pci chip device ids */
   26         MGA2064         = 0x0519,
   27         MGA2164         = 0x051B,
   28         MGA2164AGP      = 0x051F
   29 };
   30 
   31 static Pcidev*
   32 mgapcimatch(void)
   33 {
   34         Pcidev *p;
   35 
   36         p = pcimatch(nil, MATROX, MGA2164AGP);
   37         if(p == nil) {
   38                 p = pcimatch(nil, MATROX, MGA2164);
   39                 if(p == nil)
   40                         p = pcimatch(nil, MATROX, MGA2064);
   41         }
   42         return p;
   43 }
   44 
   45 static void
   46 mga2164wenable(VGAscr* scr)
   47 {
   48         Pcidev *p;
   49 
   50         if(scr->mmio)
   51                 return;
   52 
   53         p = mgapcimatch();
   54         if(p == nil)
   55                 return;
   56 
   57         if(p->did == MGA2064){
   58                 scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
   59                 if(scr->mmio == nil)
   60                         return;
   61                 addvgaseg("mga2164wmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
   62                 vgalinearaddr(scr, p->mem[1].bar&~0x0F, 8*MB);
   63         }else{
   64                 scr->mmio = vmap(p->mem[1].bar&~0x0F, p->mem[1].size);
   65                 if(scr->mmio == nil)
   66                         return;
   67                 addvgaseg("mga2164wmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
   68                 vgalinearaddr(scr, p->mem[0].bar&~0x0F, 16*MB);
   69         }
   70         if(scr->paddr)
   71                 addvgaseg("mga2164wscreen", scr->paddr, scr->apsize);
   72 }
   73 
   74 enum {
   75         Index           = 0x00,         /* Index */
   76         Data            = 0x0A,         /* Data */
   77 
   78         CaddrW          = 0x04,         /* Colour Write Address */
   79         Cdata           = 0x05,         /* Colour Data */
   80 
   81         Cctl            = 0x09,         /* Direct Cursor Control */
   82         Cram            = 0x0B,         /* Cursor Ram Data */
   83         Cxlsb           = 0x0C,         /* Cursor X LSB */
   84         Cxmsb           = 0x0D,         /* Cursor X MSB */
   85         Cylsb           = 0x0E,         /* Cursor Y LSB */
   86         Cymsb           = 0x0F,         /* Cursor Y MSB */
   87 
   88         Icctl           = 0x06,         /* Indirect Cursor Control */
   89 };
   90 
   91 static void
   92 tvp3026disable(VGAscr* scr)
   93 {
   94         uchar *tvp3026;
   95 
   96         if(scr->mmio == 0)
   97                 return;
   98         tvp3026 = (uchar*)scr->mmio+0x3C00;
   99 
  100         /*
  101          * Make sure cursor is off
  102          * and direct control enabled.
  103          */
  104         *(tvp3026+Index) = Icctl;
  105         *(tvp3026+Data) = 0x90;
  106         *(tvp3026+Cctl) = 0x00;
  107 }
  108 
  109 static void
  110 tvp3026load(VGAscr* scr, Cursor* curs)
  111 {
  112         int x, y;
  113         uchar *tvp3026;
  114 
  115         if(scr->mmio == 0)
  116                 return;
  117         tvp3026 = (uchar*)scr->mmio+0x3C00;
  118 
  119         /*
  120          * Make sure cursor is off by initialising the cursor
  121          * control to defaults.
  122          * Write to the indirect control register to make sure
  123          * direct register is enabled and upper 2 bits of cursor
  124          * RAM address are 0.
  125          * Put 0 in index register for lower 8 bits of cursor RAM address.
  126          */
  127         tvp3026disable(scr);
  128         *(tvp3026+Index) = 0;
  129 
  130         /*
  131          * Initialise the 64x64 cursor RAM array. There are 2 planes,
  132          * p0 and p1. Data is written 8 pixels per byte, with p0 in the
  133          * first 512 bytes of the array and p1 in the second.
  134          * The cursor is set in 3-colour mode which gives the following
  135          * truth table:
  136          *      p1 p0   colour
  137          *       0  0   transparent
  138          *       0  1   cursor colour 0
  139          *       1  0   cursor colour 1
  140          *       1  1   cursor colour 2
  141          * Put the cursor into the top-left of the 64x64 array.
  142          * The 0,0 cursor point is bottom-right, so positioning will
  143          * have to take that into account.
  144          */
  145         for(y = 0; y < 64; y++){
  146                 for(x = 0; x < 64/8; x++){
  147                         if(x < 16/8 && y < 16)
  148                                 *(tvp3026+Cram) = curs->clr[x+y*2];
  149                         else
  150                                 *(tvp3026+Cram) = 0x00;
  151                 }
  152         }
  153         for(y = 0; y < 64; y++){
  154                 for(x = 0; x < 64/8; x++){
  155                         if(x < 16/8 && y < 16)
  156                                 *(tvp3026+Cram) = curs->set[x+y*2];
  157                         else
  158                                 *(tvp3026+Cram) = 0x00;
  159                 }
  160         }
  161 
  162         /*
  163          * Initialise the cursor hotpoint
  164          * and enable the cursor in 3-colour mode.
  165          */
  166         scr->offset.x = 64+curs->offset.x;
  167         scr->offset.y = 64+curs->offset.y;
  168         *(tvp3026+Cctl) = 0x01;
  169 }
  170 
  171 static int
  172 tvp3026move(VGAscr* scr, Point p)
  173 {
  174         int x, y;
  175         uchar *tvp3026;
  176 
  177         if(scr->mmio == 0)
  178                 return 1;
  179         tvp3026 = (uchar*)scr->mmio+0x3C00;
  180 
  181         x = p.x+scr->offset.x;
  182         y = p.y+scr->offset.y;
  183 
  184         *(tvp3026+Cxlsb) = x & 0xFF;
  185         *(tvp3026+Cxmsb) = (x>>8) & 0x0F;
  186         *(tvp3026+Cylsb) = y & 0xFF;
  187         *(tvp3026+Cymsb) = (y>>8) & 0x0F;
  188 
  189         return 0;
  190 }
  191 
  192 static void
  193 tvp3026enable(VGAscr* scr)
  194 {
  195         int i;
  196         uchar *tvp3026;
  197 
  198         if(scr->mmio == 0)
  199                 return;
  200         tvp3026 = (uchar*)scr->mmio+0x3C00;
  201 
  202         tvp3026disable(scr);
  203 
  204         /*
  205          * Overscan colour,
  206          * cursor colour 1 (white),
  207          * cursor colour 2, 3 (black).
  208          */
  209         *(tvp3026+CaddrW) = 0x00;
  210         for(i = 0; i < 6; i++)
  211                 *(tvp3026+Cdata) = Pwhite; 
  212         for(i = 0; i < 6; i++)
  213                 *(tvp3026+Cdata) = Pblack; 
  214 
  215         /*
  216          * Load, locate and enable the
  217          * 64x64 cursor in 3-colour mode.
  218          */
  219         tvp3026load(scr, &arrow);
  220         tvp3026move(scr, ZP);
  221         *(tvp3026+Cctl) = 0x01;
  222 }
  223 
  224 VGAdev vgamga2164wdev = {
  225         "mga2164w",
  226 
  227         mga2164wenable,                 /* enable */
  228         0,                              /* disable */
  229         0,                              /* page */
  230         0,                              /* linear */
  231 };
  232 
  233 VGAcur vgamga2164wcur = {
  234         "mga2164whwgc",
  235 
  236         tvp3026enable,
  237         tvp3026disable,
  238         tvp3026load,
  239         tvp3026move,
  240 };

Cache object: 2a2537a5c348cc98b080d91bfd38f545


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.