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/xcfb_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:        xcfb_misc.c,v $
   29  * Revision 2.5  93/01/14  17:22:26  danner
   30  *      Added support for different monitors.
   31  *      [92/11/30            jtp]
   32  * 
   33  * Revision 2.4  92/05/22  15:48:39  jfriedl
   34  *      Avoid spls and use SCREEN_BEING_UPDATED instead.
   35  *      [92/05/21  18:52:03  af]
   36  * 
   37  * Revision 2.3  92/03/05  11:37:07  rpd
   38  *      Got cursor to work.
   39  *      [92/03/04            af]
   40  * 
   41  * Revision 2.2  92/03/02  18:33:17  rpd
   42  *      Created, largely incomplete pending info on cursor chip.
   43  *      [92/03/02  01:53:40  af]
   44  * 
   45  */
   46 /*
   47  *      File: xcfb_misc.c
   48  *      Author: Alessandro Forin, Carnegie Mellon University
   49  *      Date:   1/92
   50  *
   51  *      Driver for the MAXine color framebuffer
   52  *
   53  */
   54 
   55 #include <xcfb.h>
   56 #if     (NXCFB > 0)
   57 
   58 /*
   59  * NOTE: This driver relies heavily on the pm one.
   60  */
   61 
   62 #include <device/device_types.h>
   63 
   64 #include <chips/screen_defs.h>
   65 
   66 #include <chips/xcfb_monitor.h>
   67 #include <chips/pm_defs.h>
   68 typedef pm_softc_t      xcfb_softc_t;
   69 
   70 #include <chips/ims332.h>
   71 #define ims332          cursor_registers
   72 
   73 
   74 /*
   75  * Initialize color map, for kernel use
   76  */
   77 xcfb_init_colormap(sc)
   78         screen_softc_t  sc;
   79 {
   80         xcfb_softc_t    *xcfb = (xcfb_softc_t*)sc->hw_state;
   81         user_info_t     *up = sc->up;
   82         color_map_t     Bg_Fg[2];
   83         register int    i;
   84 
   85         ims332_init_colormap( xcfb->ims332 );
   86 
   87         /* init bg/fg colors */
   88         for (i = 0; i < 3; i++) {
   89                 up->dev_dep_2.pm.Bg_color[i] = 0x00;
   90                 up->dev_dep_2.pm.Fg_color[i] = 0xff;
   91         }
   92 
   93         Bg_Fg[0].red = Bg_Fg[0].green = Bg_Fg[0].blue = 0x00;
   94         Bg_Fg[1].red = Bg_Fg[1].green = Bg_Fg[1].blue = 0xff;
   95         ims332_cursor_color( xcfb->ims332, Bg_Fg);
   96 }
   97 
   98 /*
   99  * Large viz small cursor
  100  */
  101 xcfb_small_cursor_to_large(up, cursor)
  102         user_info_t     *up;
  103         cursor_sprite_t cursor;
  104 {
  105         unsigned short  new_cursor[32];
  106         unsigned char   *cursor_bytes;
  107         char            *sprite;
  108         register int    i;
  109 
  110         /* Clear out old cursor */
  111         bzero(  up->dev_dep_2.pm.cursor_sprite,
  112                 sizeof(up->dev_dep_2.pm.cursor_sprite));
  113 
  114         /* small cursor is 32x2 bytes, fg first */
  115         cursor_bytes = (unsigned char *) cursor;
  116 
  117         /* use the upper left corner of the large cursor
  118          * as a 64x1 cursor, fg&bg alternated */
  119         for (i = 0; i < 32; i++) {
  120                 register short          nc = 0;
  121                 register unsigned char  fg, bg;
  122                 register int            j, k;
  123 
  124                 fg = cursor_bytes[i];
  125                 bg = cursor_bytes[i + 32];
  126                 bg &= ~fg;
  127                 for (j = 1, k = 0; j < 256; j <<= 1) {
  128                         nc |= (bg & j) << (k++);
  129                         nc |= (fg & j) << (k);
  130                 }
  131                 new_cursor[i] = nc;
  132         }
  133 
  134         /* Now stick it in the proper place */
  135 
  136         cursor_bytes = (unsigned char *) new_cursor;
  137         sprite = up->dev_dep_2.pm.cursor_sprite;
  138         for (i = 0; i < 64; i += 4) {
  139                 *sprite++ = cursor_bytes[i + 0];
  140                 *sprite++ = cursor_bytes[i + 1];
  141                 *sprite++ = cursor_bytes[i + 2];
  142                 *sprite++ = cursor_bytes[i + 3];
  143                 sprite += 12; /* skip rest of the line */
  144         }
  145 }
  146 
  147 
  148 /*
  149  * Device-specific set status
  150  */
  151 xcfb_set_status(sc, flavor, status, status_count)
  152         screen_softc_t  sc;
  153         int             flavor;
  154         dev_status_t    status;
  155         unsigned int    status_count;
  156 {
  157         xcfb_softc_t            *xcfb = (xcfb_softc_t*) sc->hw_state;
  158 
  159         switch (flavor) {
  160 
  161         case SCREEN_ADJ_MAPPED_INFO:
  162                 return pm_set_status(sc, flavor, status, status_count);
  163 
  164         case SCREEN_LOAD_CURSOR:
  165 
  166                 if (status_count < sizeof(cursor_sprite_t)/sizeof(int))
  167                         return D_INVALID_SIZE;
  168 
  169                 xcfb_small_cursor_to_large(sc->up, (cursor_sprite_t*) status);
  170 
  171                 /* Fall through */
  172 
  173         case SCREEN_LOAD_CURSOR_LONG: /* 3max only */
  174 
  175                 sc->flags |= SCREEN_BEING_UPDATED;
  176                 ims332_cursor_sprite(xcfb->ims332, sc->up->dev_dep_2.pm.cursor_sprite);
  177                 sc->flags &= ~SCREEN_BEING_UPDATED;
  178 
  179                 break;
  180              
  181         case SCREEN_SET_CURSOR_COLOR: {
  182                 color_map_t             c[2];
  183                 register cursor_color_t *cc = (cursor_color_t*) status;
  184 
  185                 c[0].red   = cc->Bg_rgb[0];
  186                 c[0].green = cc->Bg_rgb[1];
  187                 c[0].blue  = cc->Bg_rgb[2];
  188                 c[1].red   = cc->Fg_rgb[0];
  189                 c[1].green = cc->Fg_rgb[1];
  190                 c[1].blue  = cc->Fg_rgb[2];
  191 
  192                 sc->flags |= SCREEN_BEING_UPDATED;
  193                 ims332_cursor_color (xcfb->ims332, c );
  194                 sc->flags &= ~SCREEN_BEING_UPDATED;
  195 
  196                 break;
  197         }
  198 
  199         case SCREEN_SET_CMAP_ENTRY: {
  200                 color_map_entry_t       *e = (color_map_entry_t*) status;
  201 
  202                 if (e->index < 256) {
  203                         sc->flags |= SCREEN_BEING_UPDATED;
  204                         ims332_load_colormap_entry( xcfb->ims332, e->index, &e->value);
  205                         sc->flags &= ~SCREEN_BEING_UPDATED;
  206                 }
  207                 break;
  208         }
  209 
  210         default:
  211                 return D_INVALID_OPERATION;
  212         }
  213         return D_SUCCESS;
  214 }
  215 
  216 /*
  217  * Hardware initialization
  218  */
  219 xcfb_init_screen(xcfb)
  220         xcfb_softc_t *xcfb;
  221 {
  222         extern xcfb_monitor_type_t xcfb_get_monitor_type();
  223 
  224         ims332_init( xcfb->ims332, xcfb->vdac_registers, xcfb_get_monitor_type());
  225 }
  226 
  227 /*
  228  * Do what's needed when X exits
  229  */
  230 xcfb_soft_reset(sc)
  231         screen_softc_t  sc;
  232 {
  233         xcfb_softc_t    *xcfb = (xcfb_softc_t*) sc->hw_state;
  234         user_info_t     *up =  sc->up;
  235         extern cursor_sprite_t  dc503_default_cursor;
  236 
  237         /*
  238          * Restore params in mapped structure
  239          */
  240         pm_init_screen_params(sc,up);
  241         up->row = up->max_row - 1;
  242 
  243         up->dev_dep_2.pm.x26 = 2; /* you do not want to know */
  244         up->dev_dep_1.pm.x18 = (short*)2;
  245 
  246         /*
  247          * Restore RAMDAC chip to default state
  248          */
  249         xcfb_init_screen(xcfb);
  250 
  251         /*
  252          * Load kernel's cursor sprite: just use the same pmax one
  253          */
  254         xcfb_small_cursor_to_large(up, dc503_default_cursor);
  255         ims332_cursor_sprite(xcfb->ims332, up->dev_dep_2.pm.cursor_sprite);
  256 
  257         /*
  258          * Color map and cursor color
  259          */
  260         xcfb_init_colormap(sc);
  261 }
  262 
  263 
  264 
  265 
  266 #endif  (NXCFB > 0)

Cache object: 1c98ff12798df39904fa50c22a1e55f1


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