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/chips/bt459.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 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        bt459.c,v $
   29  * Revision 2.10  93/03/17  17:10:32  mrt
   30  *      Added memory barriers for where they are needed.
   31  *      Prototypes.  Use sparse space for Flamingo.
   32  *      [93/03/10            af]
   33  * 
   34  * Revision 2.9  93/02/05  08:04:49  danner
   35  *      Flamingo (more flexible reg accesses).
   36  *      I don't think its working right, its using dense space.
   37  *      [93/02/04  01:46:58  af]
   38  * 
   39  * Revision 2.8  92/05/22  15:46:42  jfriedl
   40  *      Made loading the cursor bitmap a bit faster.
   41  *      [92/05/21  18:53:06  af]
   42  * 
   43  *      A careful re-reading of the specs revealed that we
   44  *      better poke th ereset *after* setting cmd-0, to
   45  *      allow for the pipeline to settle properly.
   46  *      Even if the prom already had it right.
   47  *      [92/05/20  22:46:09  af]
   48  * 
   49  *      Init function now takes an extra argument, to specify
   50  *      what mux factor to use. On 2D/3D it is 5:1.
   51  *      [92/05/13  20:45:06  af]
   52  * 
   53  * Revision 2.7  91/08/24  11:50:27  af
   54  *      Moved padding of regmap here, in implementation file.
   55  *      [91/08/02  02:03:12  af]
   56  * 
   57  * Revision 2.6  91/06/19  11:45:58  rvb
   58  *      File moved here from mips/PMAX since it tries to be generic.
   59  *      [91/06/04            rvb]
   60  * 
   61  * Revision 2.5  91/05/14  17:19:19  mrt
   62  *      Correcting copyright
   63  * 
   64  * Revision 2.4  91/02/05  17:39:37  mrt
   65  *      Added author notices
   66  *      [91/02/04  11:11:51  mrt]
   67  * 
   68  *      Changed to use new Mach copyright
   69  *      [91/02/02  12:09:30  mrt]
   70  * 
   71  * Revision 2.3  90/12/05  23:30:23  af
   72  *      [90/12/03  23:06:29  af]
   73  * 
   74  *      3-Sep-90  Alessandro Forin (af) at Carnegie-Mellon University
   75  *      Created, from the Brooktree data sheets:
   76  *      "Bt459 135 MHz Monolithic CMOS 256x64 Color Palette RAMDAC"
   77  *      LA59001 Rev. J
   78  */
   79 /*
   80  *      File: bt459.c
   81  *      Author: Alessandro Forin, Carnegie Mellon University
   82  *      Date:   9/90
   83  *
   84  *      Routines for the bt459 RAMDAC   
   85  */
   86 
   87 #include <platforms.h>
   88 
   89 #include <chips/bt459.h>
   90 #include <chips/screen.h>
   91 
   92 #ifdef  DECSTATION
   93 
   94 typedef struct {
   95         volatile unsigned char  addr_lo;
   96         char                                            pad0[3];
   97         volatile unsigned char  addr_hi;
   98         char                                            pad1[3];
   99         volatile unsigned char  addr_reg;
  100         char                                            pad2[3];
  101         volatile unsigned char  addr_cmap;
  102         char                                            pad3[3];
  103 } bt459_ds_padded_regmap_t;
  104 #define bt459_padded_regmap_t   bt459_ds_padded_regmap_t
  105 
  106 #define mb()    /* no write/read reordering problems */
  107 
  108 #endif  /* DECSTATION */
  109 
  110 #ifdef  FLAMINGO
  111 
  112 /* Sparse space ! */
  113 typedef struct {
  114         volatile unsigned int   addr_lo;
  115         int                                             pad0;
  116         volatile unsigned int   addr_hi;
  117         int                                             pad1;
  118         volatile unsigned int   addr_reg;
  119         int                                             pad2;
  120         volatile unsigned int   addr_cmap;
  121         int                                             pad3;
  122 } bt459_fl_padded_regmap_t;
  123 #define bt459_padded_regmap_t   bt459_fl_padded_regmap_t
  124 
  125 #define mb()    wbflush()
  126 
  127 #endif  /* FLAMINGO */
  128 
  129 
  130 #ifndef bt459_padded_regmap_t
  131 typedef bt459_regmap_t  bt459_padded_regmap_t;
  132 #define wbflush()
  133 #endif
  134 
  135 /*
  136  * Generic register access
  137  */
  138 #define bt459_select_reg_macro(r,n)             \
  139         (r)->addr_lo = (n); mb();               \
  140         (r)->addr_hi = (n) >> 8;                \
  141         wbflush();
  142 
  143 void
  144 bt459_select_reg(
  145         bt459_padded_regmap_t   *regs,
  146         int                     regno)
  147 {
  148         bt459_select_reg_macro( regs, regno);
  149 }
  150 
  151 void 
  152 bt459_write_reg(
  153         bt459_padded_regmap_t   *regs,
  154         int                     regno,
  155         unsigned char           val)
  156 {
  157         bt459_select_reg_macro( regs, regno );
  158         regs->addr_reg = val;
  159         wbflush();
  160 }
  161 
  162 unsigned char
  163 bt459_read_reg(
  164         bt459_padded_regmap_t   *regs,
  165         int                     regno)
  166 {
  167         bt459_select_reg_macro( regs, regno );
  168         return regs->addr_reg;
  169 }
  170 
  171 
  172 /*
  173  * Color map
  174  */
  175 bt459_load_colormap_entry(
  176         bt459_padded_regmap_t   *regs,
  177         int                     entry,
  178         color_map_t             *map)
  179 {
  180         bt459_select_reg(regs, entry & 0xff);
  181 
  182         regs->addr_cmap = map->red;
  183         wbflush();
  184         regs->addr_cmap = map->green;
  185         wbflush();
  186         regs->addr_cmap = map->blue;
  187         wbflush();
  188 }
  189 
  190 bt459_init_colormap(
  191         bt459_padded_regmap_t   *regs)
  192 {
  193         register int    i;
  194 
  195         bt459_select_reg(regs, 0);
  196         regs->addr_cmap = 0;
  197         wbflush();
  198         regs->addr_cmap = 0;
  199         wbflush();
  200         regs->addr_cmap = 0;
  201         wbflush();
  202 
  203         regs->addr_cmap = 0xff;
  204         wbflush();
  205         regs->addr_cmap = 0xff;
  206         wbflush();
  207         regs->addr_cmap = 0xff;
  208         wbflush();
  209 
  210         bt459_select_reg(regs, 255);
  211         regs->addr_cmap = 0xff;
  212         wbflush();
  213         regs->addr_cmap = 0xff;
  214         wbflush();
  215         regs->addr_cmap = 0xff;
  216         wbflush();
  217 
  218 }
  219 
  220 #if     1/*debug*/
  221 bt459_print_colormap(
  222         bt459_padded_regmap_t   *regs)
  223 {
  224         register int    i;
  225 
  226         for (i = 0; i < 256; i++) {
  227                 register unsigned char red, green, blue;
  228 
  229                 bt459_select_reg(regs, i);
  230                 red   = regs->addr_cmap; wbflush();
  231                 green = regs->addr_cmap; wbflush();
  232                 blue  = regs->addr_cmap; wbflush();
  233                 printf("%x->[x%x x%x x%x]\n", i,
  234                         red, green, blue);
  235 
  236         }
  237 }
  238 #endif
  239 
  240 /*
  241  * Video on/off
  242  *
  243  * It is unfortunate that X11 goes backward with white@0
  244  * and black@1.  So we must stash away the zero-th entry
  245  * and fix it while screen is off.  Also must remember
  246  * it, sigh.
  247  */
  248 struct vstate {
  249         bt459_padded_regmap_t   *regs;
  250         unsigned short  off;
  251 };
  252 
  253 bt459_video_off(
  254         struct vstate   *vstate,
  255         user_info_t     *up)
  256 {
  257         register bt459_padded_regmap_t  *regs = vstate->regs;
  258         unsigned char           *save;
  259 
  260         if (vstate->off)
  261                 return;
  262 
  263         /* Yes, this is awful */
  264         save = (unsigned char *)up->dev_dep_2.gx.colormap;
  265 
  266         bt459_select_reg(regs, 0);
  267         *save++ = regs->addr_cmap;
  268         *save++ = regs->addr_cmap;
  269         *save++ = regs->addr_cmap;
  270 
  271         bt459_select_reg(regs, 0);
  272         regs->addr_cmap = 0;
  273         wbflush();
  274         regs->addr_cmap = 0;
  275         wbflush();
  276         regs->addr_cmap = 0;
  277         wbflush();
  278 
  279         bt459_write_reg( regs, BT459_REG_PRM, 0);
  280         bt459_write_reg( regs, BT459_REG_CCR, 0);
  281 
  282         vstate->off = 1;
  283 }
  284 
  285 bt459_video_on(
  286         struct vstate   *vstate,
  287         user_info_t     *up)
  288 {
  289         register bt459_padded_regmap_t  *regs = vstate->regs;
  290         unsigned char           *save;
  291 
  292         if (!vstate->off)
  293                 return;
  294 
  295         /* Like I said.. */
  296         save = (unsigned char *)up->dev_dep_2.gx.colormap;
  297 
  298         bt459_select_reg(regs, 0);
  299         regs->addr_cmap = *save++;
  300         wbflush();
  301         regs->addr_cmap = *save++;
  302         wbflush();
  303         regs->addr_cmap = *save++;
  304         wbflush();
  305 
  306         bt459_write_reg( regs, BT459_REG_PRM, 0xff);
  307         bt459_write_reg( regs, BT459_REG_CCR, 0xc0);
  308 
  309         vstate->off = 0;
  310 }
  311 
  312 /*
  313  * Cursor
  314  */
  315 bt459_pos_cursor(
  316         bt459_padded_regmap_t   *regs,
  317         register int            x,
  318         register int            y)
  319 {
  320 #define lo(v)   ((v)&0xff)
  321 #define hi(v)   (((v)&0xf00)>>8)
  322         bt459_write_reg( regs, BT459_REG_CXLO, lo(x + 219));
  323         bt459_write_reg( regs, BT459_REG_CXHI, hi(x + 219));
  324         bt459_write_reg( regs, BT459_REG_CYLO, lo(y + 34));
  325         bt459_write_reg( regs, BT459_REG_CYHI, hi(y + 34));
  326 }
  327 
  328 
  329 bt459_cursor_color(
  330         bt459_padded_regmap_t   *regs,
  331         color_map_t             *color)
  332 {
  333         register int    i;
  334 
  335         bt459_select_reg_macro( regs, BT459_REG_CCOLOR_2);
  336         for (i = 0; i < 2; i++) {
  337                 regs->addr_reg = color->red;
  338                 wbflush();
  339                 regs->addr_reg = color->green;
  340                 wbflush();
  341                 regs->addr_reg = color->blue;
  342                 wbflush();
  343                 color++;
  344         }
  345 }
  346 
  347 bt459_cursor_sprite(
  348         bt459_padded_regmap_t   *regs,
  349         unsigned char           *cursor)
  350 {
  351         register int i, j;
  352 
  353         /*
  354          * As per specs, must run a check to see if we
  355          * had contention. If so, re-write the cursor.
  356          */
  357         for (i = 0, j = 0; j < 2; j++) {
  358             /* loop once to write */
  359             for ( ; i < 1024; i++)
  360                 bt459_write_reg( regs, BT459_REG_CRAM_BASE+i, cursor[i]);
  361 
  362             /* loop to check, if fail write again */
  363             for (i = 0; i < 1024; i++)
  364                 if (bt459_read_reg( regs, BT459_REG_CRAM_BASE+i) != cursor[i])
  365                         break;
  366             if (i == 1024)
  367                 break;/* all is well now */
  368         }
  369 }
  370 
  371 /*
  372  * Initialization
  373  */
  374 bt459_init(
  375         bt459_padded_regmap_t   *regs,
  376         volatile char           *reset,
  377         int                     mux)
  378 {
  379         if (bt459_read_reg(regs, BT459_REG_ID) != 0x4a)
  380                 panic("bt459");
  381 
  382         if (mux == 4) {
  383                 /* use 4:1 input mux */
  384                 bt459_write_reg( regs, BT459_REG_CMD0, 0x40);
  385         } else if (mux == 5) {
  386                 /* use 5:1 input mux */
  387                 bt459_write_reg( regs, BT459_REG_CMD0, 0xc0);
  388         } /* else donno */
  389 
  390         *reset = 0;     /* force chip reset */
  391 
  392         /* no zooming, no panning */
  393         bt459_write_reg( regs, BT459_REG_CMD1, 0x00);
  394 
  395         /* signature test, X-windows cursor, no overlays, SYNC* PLL,
  396            normal RAM select, 7.5 IRE pedestal, do sync */
  397         bt459_write_reg( regs, BT459_REG_CMD2, 0xc2);
  398 
  399         /* get all pixel bits */        
  400         bt459_write_reg( regs, BT459_REG_PRM,  0xff);
  401 
  402         /* no blinking */
  403         bt459_write_reg( regs, BT459_REG_PBM,  0x00);
  404 
  405         /* no overlay */
  406         bt459_write_reg( regs, BT459_REG_ORM,  0x00);
  407 
  408         /* no overlay blink */
  409         bt459_write_reg( regs, BT459_REG_OBM,  0x00);
  410 
  411         /* no interleave, no underlay */
  412         bt459_write_reg( regs, BT459_REG_ILV,  0x00);
  413 
  414         /* normal operation, no signature analysis */
  415         bt459_write_reg( regs, BT459_REG_TEST, 0x00);
  416 
  417         /* no blinking, 1bit cross hair, XOR reg&crosshair,
  418            no crosshair on either plane 0 or 1,
  419            regular cursor on both planes */
  420         bt459_write_reg( regs, BT459_REG_CCR,  0xc0);
  421 
  422         /* home cursor */
  423         bt459_write_reg( regs, BT459_REG_CXLO, 0x00);
  424         bt459_write_reg( regs, BT459_REG_CXHI, 0x00);
  425         bt459_write_reg( regs, BT459_REG_CYLO, 0x00);
  426         bt459_write_reg( regs, BT459_REG_CYHI, 0x00);
  427 
  428         /* no crosshair window */
  429         bt459_write_reg( regs, BT459_REG_WXLO, 0x00);
  430         bt459_write_reg( regs, BT459_REG_WXHI, 0x00);
  431         bt459_write_reg( regs, BT459_REG_WYLO, 0x00);
  432         bt459_write_reg( regs, BT459_REG_WYHI, 0x00);
  433         bt459_write_reg( regs, BT459_REG_WWLO, 0x00);
  434         bt459_write_reg( regs, BT459_REG_WWHI, 0x00);
  435         bt459_write_reg( regs, BT459_REG_WHLO, 0x00);
  436         bt459_write_reg( regs, BT459_REG_WHHI, 0x00);
  437 }

Cache object: 7f03995b2e47a2603cb8fbea44f9af71


[ 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.