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/cfb_misc.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:        cfb_misc.c,v $
   29  * Revision 2.13  93/06/02  13:11:56  rvb
   30  *      lint
   31  * 
   32  * Revision 2.12  93/05/17  10:26:54  rvb
   33  *      Type casts, etc to quiet gcc 2.3.3 warnings
   34  * 
   35  * Revision 2.11  93/02/05  08:05:01  danner
   36  *      Flamingo, protos.
   37  *      [93/02/04  01:44:04  af]
   38  * 
   39  *      Make it share code properly with the "sfb" driver.
   40  *      [92/11/26            af]
   41  * 
   42  * Revision 2.10  92/05/22  15:46:52  jfriedl
   43  *      Avoid spls and use SCREEN_BEING_UPDATED instead.
   44  *      [92/05/21  18:52:22  af]
   45  * 
   46  *      bt459_init() changed its looks.
   47  *      [92/05/13  20:42:50  af]
   48  * 
   49  * Revision 2.9  92/03/02  18:32:03  rpd
   50  *      When first positioning the cursor use the max_row info.
   51  *      [92/03/02  01:51:07  af]
   52  * 
   53  * Revision 2.8  92/01/17  11:45:06  rpd
   54  *      Fixed SCREEN_SET_CURSOR_COLOR to correctly convert the arguments
   55  *      before shipping them to the chip. Cures a long standing bug.
   56  *      [92/01/06            af]
   57  * 
   58  * Revision 2.7  91/08/24  11:51:34  af
   59  *      CharRows is gone, pm_init_screen_params() is different.
   60  *      [91/08/02  02:00:39  af]
   61  * 
   62  * Revision 2.6  91/06/19  11:47:19  rvb
   63  *      File moved here from mips/PMAX since it tries to be generic.
   64  *      [91/06/04            rvb]
   65  * 
   66  * Revision 2.5  91/05/14  17:20:10  mrt
   67  *      Correcting copyright
   68  * 
   69  * Revision 2.4  91/02/05  17:40:08  mrt
   70  *      Added author notices
   71  *      [91/02/04  11:12:28  mrt]
   72  * 
   73  *      Changed to use new Mach copyright
   74  *      [91/02/02  12:10:16  mrt]
   75  * 
   76  * Revision 2.3  90/12/05  23:30:37  af
   77  *      Cleaned up.
   78  *      [90/12/03  23:12:16  af]
   79  * 
   80  * Revision 2.1.1.1  90/11/01  03:42:15  af
   81  *      Created, from the DEC specs:
   82  *      "PMAG-BA TURBOchannel Color Frame Buffer Functional Specification"
   83  *      Workstation Systems Engineering, Palo Alto, CA. Aug 27, 1990
   84  *      [90/09/03            af]
   85  */
   86 /*
   87  *      File: cfb_misc.c
   88  *      Author: Alessandro Forin, Carnegie Mellon University
   89  *      Date:   9/90
   90  *
   91  *      Driver for the PMAG-BA simple color framebuffer
   92  *
   93  */
   94 
   95 #include <cfb.h>
   96 #include <sfb.h>        /* shares code */
   97 #if     ((NCFB > 0) || (NSFB > 0))
   98 #include <platforms.h>
   99 
  100 /*
  101  * NOTE: This driver relies heavily on the pm one.
  102  */
  103 
  104 #include <device/device_types.h>
  105 #include <chips/screen_defs.h>
  106 #include <chips/pm_defs.h>
  107 typedef pm_softc_t      cfb_softc_t;
  108 
  109 #include <chips/bt459.h>
  110 #define bt459           cursor_registers
  111 
  112 #ifdef  DECSTATION
  113 #include <mips/PMAX/pmag_ba.h>
  114 #endif
  115 
  116 #ifdef  FLAMINGO
  117 #include <mips/PMAX/pmag_ba.h>          /* XXX fixme */
  118 #endif
  119 
  120 /*
  121  * Initialize color map, for kernel use
  122  */
  123 cfb_init_colormap(
  124         screen_softc_t  sc)
  125 {
  126         cfb_softc_t     *cfb = (cfb_softc_t*)sc->hw_state;
  127         user_info_t     *up = sc->up;
  128         color_map_t     Bg_Fg[2];
  129         register int    i;
  130 
  131         bt459_init_colormap( cfb->bt459 );
  132 
  133         /* init bg/fg colors */
  134         for (i = 0; i < 3; i++) {
  135                 up->dev_dep_2.pm.Bg_color[i] = 0x00;
  136                 up->dev_dep_2.pm.Fg_color[i] = 0xff;
  137         }
  138 
  139         Bg_Fg[0].red = Bg_Fg[0].green = Bg_Fg[0].blue = 0x00;
  140         Bg_Fg[1].red = Bg_Fg[1].green = Bg_Fg[1].blue = 0xff;
  141         bt459_cursor_color( cfb->bt459, Bg_Fg);
  142 }
  143 
  144 /*
  145  * Large viz small cursor
  146  */
  147 cfb_small_cursor_to_large(
  148         user_info_t     *up,
  149         cursor_sprite_t cursor)
  150 {
  151         unsigned short new_cursor[32];
  152         unsigned char  *curbytes, fg, fbg;
  153         int             i, j, k;
  154         char           *sprite;
  155 
  156         /* Clear out old cursor */
  157         bzero(  up->dev_dep_2.pm.cursor_sprite,
  158                 sizeof(up->dev_dep_2.pm.cursor_sprite));
  159 
  160         /* small cursor is 32x2 bytes, fg first */
  161         curbytes = (unsigned char *) cursor;
  162 
  163         /* use the upper left corner of the large cursor
  164          * as a 64x1 cursor, fg&bg alternated */
  165         for (i = 0; i < 32; i++) {
  166                 fg = curbytes[i];
  167                 fbg = fg | curbytes[i + 32];
  168                 new_cursor[i] = 0;
  169                 for (j = 0, k = 15; j < 8; j++, k -= 2) {
  170                         new_cursor[i] |= ((fbg >> j) & 0x1) << (k);
  171                         new_cursor[i] |= ((fg >> j) & 0x1) << (k - 1);
  172                 }
  173         }
  174 
  175         /* Now stick it in the proper place */
  176 
  177         curbytes = (unsigned char *) new_cursor;
  178         sprite = up->dev_dep_2.pm.cursor_sprite;
  179         for (i = 0; i < 64; i += 4) {
  180                 /* butterfly as we go */
  181                 *sprite++ = curbytes[i + 1];
  182                 *sprite++ = curbytes[i + 0];
  183                 *sprite++ = curbytes[i + 3];
  184                 *sprite++ = curbytes[i + 2];
  185                 sprite += 12; /* skip rest of the line */
  186         }
  187 }
  188 
  189 
  190 /*
  191  * Device-specific set status
  192  */
  193 cfb_set_status(
  194         screen_softc_t  sc,
  195         dev_flavor_t    flavor,
  196         dev_status_t    status,
  197         natural_t       status_count)
  198 {
  199         cfb_softc_t             *cfb = (cfb_softc_t*) sc->hw_state;
  200 
  201         switch (flavor) {
  202 
  203         case SCREEN_ADJ_MAPPED_INFO:
  204                 return pm_set_status(sc, flavor, status, status_count);
  205 
  206         case SCREEN_LOAD_CURSOR:
  207 
  208                 if (status_count < sizeof(cursor_sprite_t)/sizeof(int))
  209                         return D_INVALID_SIZE;
  210 /*              cfb_small_cursor_to_large(sc->up, (cursor_sprite_t) status);*/
  211                 cfb_small_cursor_to_large(sc->up, (unsigned short *) status);
  212 
  213                 /* Fall through */
  214 
  215         case SCREEN_LOAD_CURSOR_LONG: /* 3max only */
  216 
  217                 sc->flags |= SCREEN_BEING_UPDATED;
  218                 bt459_cursor_sprite(cfb->bt459, sc->up->dev_dep_2.pm.cursor_sprite);
  219                 sc->flags &= ~SCREEN_BEING_UPDATED;
  220 
  221                 break;
  222              
  223         case SCREEN_SET_CURSOR_COLOR: {
  224                 color_map_t             c[2];
  225                 register cursor_color_t *cc = (cursor_color_t*) status;
  226 
  227                 c[0].red   = cc->Bg_rgb[0];
  228                 c[0].green = cc->Bg_rgb[1];
  229                 c[0].blue  = cc->Bg_rgb[2];
  230                 c[1].red   = cc->Fg_rgb[0];
  231                 c[1].green = cc->Fg_rgb[1];
  232                 c[1].blue  = cc->Fg_rgb[2];
  233 
  234                 sc->flags |= SCREEN_BEING_UPDATED;
  235                 bt459_cursor_color (cfb->bt459, c );
  236                 sc->flags &= ~SCREEN_BEING_UPDATED;
  237 
  238                 break;
  239         }
  240 
  241         case SCREEN_SET_CMAP_ENTRY: {
  242                 color_map_entry_t       *e = (color_map_entry_t*) status;
  243 
  244                 if (e->index < 256) {
  245                         sc->flags |= SCREEN_BEING_UPDATED;
  246                         bt459_load_colormap_entry( cfb->bt459, e->index, &e->value);
  247                         sc->flags &= ~SCREEN_BEING_UPDATED;
  248                 }
  249                 break;
  250         }
  251 
  252         default:
  253                 return D_INVALID_OPERATION;
  254         }
  255         return D_SUCCESS;
  256 }
  257 
  258 #if (NCFB > 0)
  259 /*
  260  * Hardware initialization
  261  */
  262 cfb_init_screen(
  263         cfb_softc_t *cfb)
  264 {
  265         bt459_init( cfb->bt459,
  266                     cfb->bt459 + (CFB_OFFSET_RESET - CFB_OFFSET_BT459),
  267                     4 /* 4:1 MUX */);
  268 }
  269 
  270 /*
  271  * Do what's needed when X exits
  272  */
  273 cfb_soft_reset(
  274         screen_softc_t  sc)
  275 {
  276         cfb_softc_t     *cfb = (cfb_softc_t*) sc->hw_state;
  277         user_info_t     *up =  sc->up;
  278         extern cursor_sprite_t  dc503_default_cursor;
  279 
  280         /*
  281          * Restore params in mapped structure
  282          */
  283         pm_init_screen_params(sc,up);
  284         up->row = up->max_row - 1;
  285 
  286         up->dev_dep_2.pm.x26 = 2; /* you do not want to know */
  287         up->dev_dep_1.pm.x18 = (short*)2;
  288 
  289         /*
  290          * Restore RAMDAC chip to default state
  291          */
  292         cfb_init_screen(cfb);
  293 
  294         /*
  295          * Load kernel's cursor sprite: just use the same pmax one
  296          */
  297         cfb_small_cursor_to_large(up, dc503_default_cursor);
  298         bt459_cursor_sprite(cfb->bt459, up->dev_dep_2.pm.cursor_sprite);
  299 
  300         /*
  301          * Color map and cursor color
  302          */
  303         cfb_init_colormap(sc);
  304 }
  305 #endif  /* NCFB > 0 */
  306 
  307 
  308 
  309 #endif  /* (NCFB > 0) || (NSFB > 0) */

Cache object: 7ef989774864191bdbd2f2c4b9501fd3


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