Annotation of Gnu-Mach/chips/cfb_misc.c, revision 1.1

1.1     ! root        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  [email protected]
        !            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:  *     File: cfb_misc.c
        !            28:  *     Author: Alessandro Forin, Carnegie Mellon University
        !            29:  *     Date:   9/90
        !            30:  *
        !            31:  *     Driver for the PMAG-BA simple color framebuffer
        !            32:  *
        !            33:  */
        !            34: 
        !            35: #include <cfb.h>
        !            36: #include <sfb.h>       /* shares code */
        !            37: #if    ((NCFB > 0) || (NSFB > 0))
        !            38: #include <platforms.h>
        !            39: 
        !            40: /*
        !            41:  * NOTE: This driver relies heavily on the pm one.
        !            42:  */
        !            43: 
        !            44: #include <device/device_types.h>
        !            45: #include <chips/screen_defs.h>
        !            46: #include <chips/pm_defs.h>
        !            47: typedef pm_softc_t     cfb_softc_t;
        !            48: 
        !            49: #include <chips/bt459.h>
        !            50: #define        bt459           cursor_registers
        !            51: 
        !            52: #ifdef DECSTATION
        !            53: #include <mips/PMAX/pmag_ba.h>
        !            54: #endif
        !            55: 
        !            56: #ifdef FLAMINGO
        !            57: #include <mips/PMAX/pmag_ba.h>         /* XXX fixme */
        !            58: #endif
        !            59: 
        !            60: /*
        !            61:  * Initialize color map, for kernel use
        !            62:  */
        !            63: cfb_init_colormap(
        !            64:        screen_softc_t  sc)
        !            65: {
        !            66:        cfb_softc_t     *cfb = (cfb_softc_t*)sc->hw_state;
        !            67:        user_info_t     *up = sc->up;
        !            68:        color_map_t     Bg_Fg[2];
        !            69:        register int    i;
        !            70: 
        !            71:        bt459_init_colormap( cfb->bt459 );
        !            72: 
        !            73:        /* init bg/fg colors */
        !            74:        for (i = 0; i < 3; i++) {
        !            75:                up->dev_dep_2.pm.Bg_color[i] = 0x00;
        !            76:                up->dev_dep_2.pm.Fg_color[i] = 0xff;
        !            77:        }
        !            78: 
        !            79:        Bg_Fg[0].red = Bg_Fg[0].green = Bg_Fg[0].blue = 0x00;
        !            80:        Bg_Fg[1].red = Bg_Fg[1].green = Bg_Fg[1].blue = 0xff;
        !            81:        bt459_cursor_color( cfb->bt459, Bg_Fg);
        !            82: }
        !            83: 
        !            84: /*
        !            85:  * Large viz small cursor
        !            86:  */
        !            87: cfb_small_cursor_to_large(
        !            88:        user_info_t     *up,
        !            89:        cursor_sprite_t cursor)
        !            90: {
        !            91:        unsigned short new_cursor[32];
        !            92:        unsigned char  *curbytes, fg, fbg;
        !            93:        int             i, j, k;
        !            94:        char           *sprite;
        !            95: 
        !            96:        /* Clear out old cursor */
        !            97:        bzero(  up->dev_dep_2.pm.cursor_sprite,
        !            98:                sizeof(up->dev_dep_2.pm.cursor_sprite));
        !            99: 
        !           100:        /* small cursor is 32x2 bytes, fg first */
        !           101:        curbytes = (unsigned char *) cursor;
        !           102: 
        !           103:        /* use the upper left corner of the large cursor
        !           104:         * as a 64x1 cursor, fg&bg alternated */
        !           105:        for (i = 0; i < 32; i++) {
        !           106:                fg = curbytes[i];
        !           107:                fbg = fg | curbytes[i + 32];
        !           108:                new_cursor[i] = 0;
        !           109:                for (j = 0, k = 15; j < 8; j++, k -= 2) {
        !           110:                        new_cursor[i] |= ((fbg >> j) & 0x1) << (k);
        !           111:                        new_cursor[i] |= ((fg >> j) & 0x1) << (k - 1);
        !           112:                }
        !           113:        }
        !           114: 
        !           115:        /* Now stick it in the proper place */
        !           116: 
        !           117:        curbytes = (unsigned char *) new_cursor;
        !           118:        sprite = up->dev_dep_2.pm.cursor_sprite;
        !           119:        for (i = 0; i < 64; i += 4) {
        !           120:                /* butterfly as we go */
        !           121:                *sprite++ = curbytes[i + 1];
        !           122:                *sprite++ = curbytes[i + 0];
        !           123:                *sprite++ = curbytes[i + 3];
        !           124:                *sprite++ = curbytes[i + 2];
        !           125:                sprite += 12; /* skip rest of the line */
        !           126:        }
        !           127: }
        !           128: 
        !           129: 
        !           130: /*
        !           131:  * Device-specific set status
        !           132:  */
        !           133: cfb_set_status(
        !           134:        screen_softc_t  sc,
        !           135:        dev_flavor_t    flavor,
        !           136:        dev_status_t    status,
        !           137:        natural_t       status_count)
        !           138: {
        !           139:        cfb_softc_t             *cfb = (cfb_softc_t*) sc->hw_state;
        !           140: 
        !           141:        switch (flavor) {
        !           142: 
        !           143:        case SCREEN_ADJ_MAPPED_INFO:
        !           144:                return pm_set_status(sc, flavor, status, status_count);
        !           145: 
        !           146:        case SCREEN_LOAD_CURSOR:
        !           147: 
        !           148:                if (status_count < sizeof(cursor_sprite_t)/sizeof(int))
        !           149:                        return D_INVALID_SIZE;
        !           150: /*             cfb_small_cursor_to_large(sc->up, (cursor_sprite_t) status);*/
        !           151:                cfb_small_cursor_to_large(sc->up, (unsigned short *) status);
        !           152: 
        !           153:                /* Fall through */
        !           154: 
        !           155:        case SCREEN_LOAD_CURSOR_LONG: /* 3max only */
        !           156: 
        !           157:                sc->flags |= SCREEN_BEING_UPDATED;
        !           158:                bt459_cursor_sprite(cfb->bt459, sc->up->dev_dep_2.pm.cursor_sprite);
        !           159:                sc->flags &= ~SCREEN_BEING_UPDATED;
        !           160: 
        !           161:                break;
        !           162:             
        !           163:        case SCREEN_SET_CURSOR_COLOR: {
        !           164:                color_map_t             c[2];
        !           165:                register cursor_color_t *cc = (cursor_color_t*) status;
        !           166: 
        !           167:                c[0].red   = cc->Bg_rgb[0];
        !           168:                c[0].green = cc->Bg_rgb[1];
        !           169:                c[0].blue  = cc->Bg_rgb[2];
        !           170:                c[1].red   = cc->Fg_rgb[0];
        !           171:                c[1].green = cc->Fg_rgb[1];
        !           172:                c[1].blue  = cc->Fg_rgb[2];
        !           173: 
        !           174:                sc->flags |= SCREEN_BEING_UPDATED;
        !           175:                bt459_cursor_color (cfb->bt459, c );
        !           176:                sc->flags &= ~SCREEN_BEING_UPDATED;
        !           177: 
        !           178:                break;
        !           179:        }
        !           180: 
        !           181:        case SCREEN_SET_CMAP_ENTRY: {
        !           182:                color_map_entry_t       *e = (color_map_entry_t*) status;
        !           183: 
        !           184:                if (e->index < 256) {
        !           185:                        sc->flags |= SCREEN_BEING_UPDATED;
        !           186:                        bt459_load_colormap_entry( cfb->bt459, e->index, &e->value);
        !           187:                        sc->flags &= ~SCREEN_BEING_UPDATED;
        !           188:                }
        !           189:                break;
        !           190:        }
        !           191: 
        !           192:        default:
        !           193:                return D_INVALID_OPERATION;
        !           194:        }
        !           195:        return D_SUCCESS;
        !           196: }
        !           197: 
        !           198: #if (NCFB > 0)
        !           199: /*
        !           200:  * Hardware initialization
        !           201:  */
        !           202: cfb_init_screen(
        !           203:        cfb_softc_t *cfb)
        !           204: {
        !           205:        bt459_init( cfb->bt459,
        !           206:                    cfb->bt459 + (CFB_OFFSET_RESET - CFB_OFFSET_BT459),
        !           207:                    4 /* 4:1 MUX */);
        !           208: }
        !           209: 
        !           210: /*
        !           211:  * Do what's needed when X exits
        !           212:  */
        !           213: cfb_soft_reset(
        !           214:        screen_softc_t  sc)
        !           215: {
        !           216:        cfb_softc_t     *cfb = (cfb_softc_t*) sc->hw_state;
        !           217:        user_info_t     *up =  sc->up;
        !           218:        extern cursor_sprite_t  dc503_default_cursor;
        !           219: 
        !           220:        /*
        !           221:         * Restore params in mapped structure
        !           222:         */
        !           223:        pm_init_screen_params(sc,up);
        !           224:        up->row = up->max_row - 1;
        !           225: 
        !           226:        up->dev_dep_2.pm.x26 = 2; /* you do not want to know */
        !           227:        up->dev_dep_1.pm.x18 = (short*)2;
        !           228: 
        !           229:        /*
        !           230:         * Restore RAMDAC chip to default state
        !           231:         */
        !           232:        cfb_init_screen(cfb);
        !           233: 
        !           234:        /*
        !           235:         * Load kernel's cursor sprite: just use the same pmax one
        !           236:         */
        !           237:        cfb_small_cursor_to_large(up, dc503_default_cursor);
        !           238:        bt459_cursor_sprite(cfb->bt459, up->dev_dep_2.pm.cursor_sprite);
        !           239: 
        !           240:        /*
        !           241:         * Color map and cursor color
        !           242:         */
        !           243:        cfb_init_colormap(sc);
        !           244: }
        !           245: #endif /* NCFB > 0 */
        !           246: 
        !           247: 
        !           248: 
        !           249: #endif /* (NCFB > 0) || (NSFB > 0) */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.