[BACK]Return to bt463.c CVS log [TXT][DIR] Up to [local] / sys / dev / ic

Annotation of sys/dev/ic/bt463.c, Revision 1.1.1.1

1.1       nbrk        1: /* $OpenBSD: bt463.c,v 1.10 2002/11/09 22:51:48 miod Exp $ */
                      2: /* $NetBSD: bt463.c,v 1.2 2000/06/13 17:21:06 nathanw Exp $ */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1998 The NetBSD Foundation, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code is derived from software contributed to The NetBSD Foundation
                      9:  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
                     10:  * NASA Ames Research Center.
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
                     20:  * 3. All advertising materials mentioning features or use of this software
                     21:  *    must display the following acknowledgement:
                     22:  *     This product includes software developed by the NetBSD
                     23:  *     Foundation, Inc. and its contributors.
                     24:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     25:  *    contributors may be used to endorse or promote products derived
                     26:  *    from this software without specific prior written permission.
                     27:  *
                     28:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     29:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     30:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     31:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     32:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     33:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     34:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     35:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     36:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     37:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     38:  * POSSIBILITY OF SUCH DAMAGE.
                     39:  */
                     40:
                     41: /*
                     42:  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
                     43:  * All rights reserved.
                     44:  *
                     45:  * Author: Chris G. Demetriou
                     46:  *
                     47:  * Permission to use, copy, modify and distribute this software and
                     48:  * its documentation is hereby granted, provided that both the copyright
                     49:  * notice and this permission notice appear in all copies of the
                     50:  * software, derivative works or modified versions, and any portions
                     51:  * thereof, and that both notices appear in supporting documentation.
                     52:  *
                     53:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     54:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
                     55:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     56:  *
                     57:  * Carnegie Mellon requests users of this software to return to
                     58:  *
                     59:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
                     60:  *  School of Computer Science
                     61:  *  Carnegie Mellon University
                     62:  *  Pittsburgh PA 15213-3890
                     63:  *
                     64:  * any improvements or extensions that they make and grant Carnegie the
                     65:  * rights to redistribute these changes.
                     66:  */
                     67:
                     68:  /* This code was derived from and originally located in sys/dev/pci/
                     69:   *     NetBSD: tga_bt463.c,v 1.5 2000/03/04 10:27:59 elric Exp
                     70:   */
                     71:
                     72: #include <sys/param.h>
                     73: #include <sys/systm.h>
                     74: #include <sys/device.h>
                     75: #include <sys/buf.h>
                     76: #include <sys/kernel.h>
                     77: #include <sys/malloc.h>
                     78:
                     79: #include <uvm/uvm_extern.h>
                     80:
                     81: #include <dev/pci/pcivar.h>
                     82: #include <dev/pci/tgareg.h>
                     83: #include <dev/pci/tgavar.h>
                     84: #include <dev/ic/bt463reg.h>
                     85: #include <dev/ic/bt463var.h>
                     86:
                     87: #include <dev/wscons/wsconsio.h>
                     88:
                     89: /*
                     90:  * Functions exported via the RAMDAC configuration table.
                     91:  */
                     92: void   bt463_init(struct ramdac_cookie *);
                     93: int    bt463_set_cmap(struct ramdac_cookie *,
                     94:            struct wsdisplay_cmap *);
                     95: int    bt463_get_cmap(struct ramdac_cookie *,
                     96:            struct wsdisplay_cmap *);
                     97: int    bt463_set_cursor(struct ramdac_cookie *,
                     98:            struct wsdisplay_cursor *);
                     99: int    bt463_get_cursor(struct ramdac_cookie *,
                    100:            struct wsdisplay_cursor *);
                    101: int    bt463_set_curpos(struct ramdac_cookie *,
                    102:            struct wsdisplay_curpos *);
                    103: int    bt463_get_curpos(struct ramdac_cookie *,
                    104:            struct wsdisplay_curpos *);
                    105: int    bt463_get_curmax(struct ramdac_cookie *,
                    106:            struct wsdisplay_curpos *);
                    107: int    bt463_check_curcmap(struct ramdac_cookie *,
                    108:            struct wsdisplay_cursor *cursorp);
                    109: void   bt463_set_curcmap(struct ramdac_cookie *,
                    110:            struct wsdisplay_cursor *cursorp);
                    111: int    bt463_get_curcmap(struct ramdac_cookie *,
                    112:            struct wsdisplay_cursor *cursorp);
                    113:
                    114: #ifdef BT463_DEBUG
                    115: int bt463_store(void *);
                    116: int bt463_debug(void *);
                    117: int bt463_readback(void *);
                    118: void   bt463_copyback(void *);
                    119: #endif
                    120:
                    121: struct ramdac_funcs bt463_funcsstruct = {
                    122:        "Bt463",
                    123:        bt463_register,
                    124:        bt463_init,
                    125:        bt463_set_cmap,
                    126:        bt463_get_cmap,
                    127:        bt463_set_cursor,
                    128:        bt463_get_cursor,
                    129:        bt463_set_curpos,
                    130:        bt463_get_curpos,
                    131:        bt463_get_curmax,
                    132:        bt463_check_curcmap,
                    133:        bt463_set_curcmap,
                    134:        bt463_get_curcmap,
                    135:        NULL,
                    136: };
                    137:
                    138: /*
                    139:  * Private data.
                    140:  */
                    141: struct bt463data {
                    142:        void            *cookie;        /* This is what is passed
                    143:                                         * around, and is probably
                    144:                                         * struct tga_devconfig *
                    145:                                         */
                    146:
                    147:        int             (*ramdac_sched_update)(void *, void (*)(void *));
                    148:        void            (*ramdac_wr)(void *, u_int, u_int8_t);
                    149:        u_int8_t        (*ramdac_rd)(void *, u_int);
                    150:
                    151:        int     changed;                        /* what changed; see below */
                    152:        char curcmap_r[2];                      /* cursor colormap */
                    153:        char curcmap_g[2];
                    154:        char curcmap_b[2];
                    155:        char cmap_r[BT463_NCMAP_ENTRIES];       /* colormap */
                    156:        char cmap_g[BT463_NCMAP_ENTRIES];
                    157:        char cmap_b[BT463_NCMAP_ENTRIES];
                    158:        int window_type[16]; /* 16 24-bit window type table entries */
                    159: };
                    160:
                    161: /* When we're doing console initialization, there's no
                    162:  * way to get our cookie back to the video card's softc
                    163:  * before we call sched_update. So we stash it here,
                    164:  * and bt463_update will look for it here first.
                    165:  */
                    166: static struct bt463data *console_data;
                    167:
                    168:
                    169: #define BTWREG(data, addr, val) do { bt463_wraddr((data), (addr)); \
                    170:        (data)->ramdac_wr((data)->cookie, BT463_REG_IREG_DATA, (val)); } while (0)
                    171: #define BTWNREG(data, val) (data)->ramdac_wr((data)->cookie, \
                    172:        BT463_REG_IREG_DATA, (val))
                    173: #define BTRREG(data, addr) (bt463_wraddr((data), (addr)), \
                    174:        (data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
                    175: #define BTRNREG(data) ((data)->ramdac_rd((data)->cookie, BT463_REG_IREG_DATA))
                    176:
                    177: #define        DATA_CURCMAP_CHANGED    0x01    /* cursor colormap changed */
                    178: #define        DATA_CMAP_CHANGED       0x02    /* colormap changed */
                    179: #define        DATA_WTYPE_CHANGED      0x04    /* window type table changed */
                    180: #define        DATA_ALL_CHANGED        0x07
                    181:
                    182: /*
                    183:  * Internal functions.
                    184:  */
                    185: inline void bt463_wraddr(struct bt463data *, u_int16_t);
                    186:
                    187: void   bt463_update(void *);
                    188:
                    189:
                    190: /*****************************************************************************/
                    191:
                    192: /*
                    193:  * Functions exported via the RAMDAC configuration table.
                    194:  */
                    195:
                    196: struct ramdac_funcs *
                    197: bt463_funcs(void)
                    198: {
                    199:        return &bt463_funcsstruct;
                    200: }
                    201:
                    202: struct ramdac_cookie *
                    203: bt463_register(v, sched_update, wr, rd)
                    204:        void *v;
                    205:        int (*sched_update)(void *, void (*)(void *));
                    206:        void (*wr)(void *, u_int, u_int8_t);
                    207:        u_int8_t (*rd)(void *, u_int);
                    208: {
                    209:        struct bt463data *data;
                    210:        /*
                    211:         * XXX -- comment out of date.  rcd.
                    212:         * If we should allocate a new private info struct, do so.
                    213:         * Otherwise, use the one we have (if it's there), or
                    214:         * use the temporary one on the stack.
                    215:         */
                    216:        data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
                    217:        /* XXX -- if !data */
                    218:        data->cookie = v;
                    219:        data->ramdac_sched_update = sched_update;
                    220:        data->ramdac_wr = wr;
                    221:        data->ramdac_rd = rd;
                    222:        return (struct ramdac_cookie *)data;
                    223: }
                    224:
                    225: /*
                    226:  * This function exists solely to provide a means to init
                    227:  * the RAMDAC without first registering.  It is useful for
                    228:  * initializing the console early on.
                    229:  */
                    230: void
                    231: bt463_cninit(v, sched_update, wr, rd)
                    232:        void *v;
                    233:        int (*sched_update)(void *, void (*)(void *));
                    234:        void (*wr)(void *, u_int, u_int8_t);
                    235:        u_int8_t (*rd)(void *, u_int);
                    236: {
                    237:        struct bt463data tmp, *data = &tmp;
                    238:        data->cookie = v;
                    239:        data->ramdac_sched_update = sched_update;
                    240:        data->ramdac_wr = wr;
                    241:        data->ramdac_rd = rd;
                    242:        /* Set up console_data so that when bt463_update is called back,
                    243:         * it can use the right information.
                    244:         */
                    245:        console_data = data;
                    246:        bt463_init((struct ramdac_cookie *)data);
                    247:        console_data = NULL;
                    248: }
                    249:
                    250: void
                    251: bt463_init(rc)
                    252:        struct ramdac_cookie *rc;
                    253: {
                    254:        struct bt463data *data = (struct bt463data *)rc;
                    255:
                    256:        int i;
                    257:
                    258:        /*
                    259:         * Init the BT463 for normal operation.
                    260:         */
                    261:
                    262:
                    263:        /*
                    264:         * Setup:
                    265:         * reg 0: 4:1 multiplexing, 25/75 blink.
                    266:         * reg 1: Overlay mapping: mapped to common palette,
                    267:         *        14 window type entries, 24-plane configuration mode,
                    268:         *        4 overlay planes, underlays disabled, no cursor.
                    269:         * reg 2: sync-on-green enabled, pedestal enabled.
                    270:         */
                    271:
                    272:        BTWREG(data, BT463_IREG_COMMAND_0, 0x40);
                    273:        BTWREG(data, BT463_IREG_COMMAND_1, 0x48);
                    274:        BTWREG(data, BT463_IREG_COMMAND_2, 0xC0);
                    275:
                    276:        /*
                    277:         * Initialize the read mask.
                    278:         */
                    279:        bt463_wraddr(data, BT463_IREG_READ_MASK_P0_P7);
                    280:        for (i = 0; i < 4; i++)
                    281:                BTWNREG(data, 0xff);
                    282:
                    283:        /*
                    284:         * Initialize the blink mask.
                    285:         */
                    286:        bt463_wraddr(data, BT463_IREG_BLINK_MASK_P0_P7);
                    287:        for (i = 0; i < 4; i++)
                    288:                BTWNREG(data, 0);
                    289:
                    290:
                    291:        /*
                    292:         * Clear test register
                    293:         */
                    294:        BTWREG(data, BT463_IREG_TEST, 0);
                    295:
                    296:        /*
                    297:         * Initalize the RAMDAC info struct to hold all of our
                    298:         * data, and fill it in.
                    299:         */
                    300:        data->changed = DATA_ALL_CHANGED;
                    301:
                    302:        /* initial cursor colormap: 0 is black, 1 is white */
                    303:        data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
                    304:        data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
                    305:
                    306:        /* Initial colormap: 0 is black, everything else is white */
                    307:        data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
                    308:        for (i = 1; i < 256; i++) {
                    309:                data->cmap_r[i] = rasops_cmap[3*i + 0];
                    310:                data->cmap_g[i] = rasops_cmap[3*i + 1];
                    311:                data->cmap_b[i] = rasops_cmap[3*i + 2];
                    312:        }
                    313:
                    314:        /* Initialize the window type table:
                    315:         *
                    316:         * Entry 0: 24-plane truecolor, overlays enabled, bypassed.
                    317:         *
                    318:         *  Lookup table bypass:      yes (    1 << 23 & 0x800000)  800000
                    319:         *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
                    320:         *  Overlay mask:             0xf (  0xf << 13 & 0x01e000)   1e000
                    321:         *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
                    322:         *  Display mode:       Truecolor (    0 <<  9 & 0x000e00)     000
                    323:         *  Number of planes:           8 (    8 <<  5 & 0x0001e0)     100
                    324:         *  Plane shift:                0 (    0 <<  0 & 0x00001f)       0
                    325:         *                                                        --------
                    326:         *                                                        0x81e100
                    327:         */
                    328:        data->window_type[0] = 0x81e100;
                    329:
                    330:        /* Entry 1: 8-plane pseudocolor in the bottom 8 bits,
                    331:         *          overlays enabled, colormap starting at 0.
                    332:         *
                    333:         *  Lookup table bypass:       no (    0 << 23 & 0x800000)       0
                    334:         *  Colormap address:       0x000 (0x000 << 17 & 0x7e0000)       0
                    335:         *  Overlay mask:             0xf (  0xf << 13 & 0x01e000) 0x1e000
                    336:         *  Overlay location:    P<27:24> (    0 << 12 & 0x001000)       0
                    337:         *  Display mode:     Pseudocolor (    1 <<  9 & 0x000e00)   0x200
                    338:         *  Number of planes:           8 (    8 <<  5 & 0x0001e0)   0x100
                    339:         *  Plane shift:               16 ( 0x10 <<  0 & 0x00001f)      10
                    340:         *                                                        --------
                    341:         *                                                        0x01e310
                    342:         */
                    343:        data->window_type[1] = 0x01e310;
                    344:
                    345:        /* The colormap interface to the world only supports one colormap,
                    346:         * so having an entry for the 'alternate' colormap in the bt463
                    347:         * probably isn't useful.
                    348:         */
                    349:
                    350:        /* Fill the remaining table entries with clones of entry 0 until we
                    351:         * figure out a better use for them.
                    352:         */
                    353:
                    354:        for (i = 2; i < BT463_NWTYPE_ENTRIES; i++) {
                    355:                data->window_type[i] = 0x81e100;
                    356:        }
                    357:
                    358:        data->ramdac_sched_update(data->cookie, bt463_update);
                    359:
                    360: }
                    361:
                    362: int
                    363: bt463_set_cmap(rc, cmapp)
                    364:        struct ramdac_cookie *rc;
                    365:        struct wsdisplay_cmap *cmapp;
                    366: {
                    367:        struct bt463data *data = (struct bt463data *)rc;
                    368:        u_int count, index;
                    369:        int s, error;
                    370:
                    371:        index = cmapp->index;
                    372:        count = cmapp->count;
                    373:
                    374:        if (index >= BT463_NCMAP_ENTRIES || count > BT463_NCMAP_ENTRIES - index)
                    375:                return (EINVAL);
                    376:
                    377:        s = spltty();
                    378:
                    379:        if ((error = copyin(cmapp->red, &data->cmap_r[index], count)) != 0) {
                    380:                splx(s);
                    381:                return (error);
                    382:        }
                    383:        if ((error = copyin(cmapp->green, &data->cmap_g[index], count)) != 0) {
                    384:                splx(s);
                    385:                return (error);
                    386:        }
                    387:        if ((error = copyin(cmapp->blue, &data->cmap_b[index], count)) != 0) {
                    388:                splx(s);
                    389:                return (error);
                    390:        }
                    391:
                    392:        data->changed |= DATA_CMAP_CHANGED;
                    393:
                    394:        data->ramdac_sched_update(data->cookie, bt463_update);
                    395:        splx(s);
                    396:
                    397:        return (0);
                    398: }
                    399:
                    400: int
                    401: bt463_get_cmap(rc, cmapp)
                    402:        struct ramdac_cookie *rc;
                    403:        struct wsdisplay_cmap *cmapp;
                    404: {
                    405:        struct bt463data *data = (struct bt463data *)rc;
                    406:        u_int count, index;
                    407:        int error;
                    408:
                    409:        count = cmapp->count;
                    410:        index = cmapp->index;
                    411:
                    412:        if (index >= BT463_NCMAP_ENTRIES || count > BT463_NCMAP_ENTRIES - index)
                    413:                return (EINVAL);
                    414:
                    415:        error = copyout(&data->cmap_r[index], cmapp->red, count);
                    416:        if (error)
                    417:                return (error);
                    418:        error = copyout(&data->cmap_g[index], cmapp->green, count);
                    419:        if (error)
                    420:                return (error);
                    421:        error = copyout(&data->cmap_b[index], cmapp->blue, count);
                    422:        return (error);
                    423: }
                    424:
                    425: int
                    426: bt463_check_curcmap(rc, cursorp)
                    427:        struct ramdac_cookie *rc;
                    428:        struct wsdisplay_cursor *cursorp;
                    429: {
                    430:        u_int index, count;
                    431:        u_int8_t spare[2];
                    432:        int error;
                    433:
                    434:        index = cursorp->cmap.index;
                    435:        count = cursorp->cmap.count;
                    436:
                    437:        if (index >= 2 || count > 2 - index)
                    438:                return (EINVAL);
                    439:
                    440:        if ((error = copyin(&cursorp->cmap.red, &spare, count)) != 0)
                    441:                return (error);
                    442:        if ((error = copyin(&cursorp->cmap.green, &spare, count)) != 0)
                    443:                return (error);
                    444:        if ((error = copyin(&cursorp->cmap.blue, &spare, count)) != 0)
                    445:                return (error);
                    446:
                    447:        return (0);
                    448: }
                    449:
                    450: void
                    451: bt463_set_curcmap(rc, cursorp)
                    452:        struct ramdac_cookie *rc;
                    453:        struct wsdisplay_cursor *cursorp;
                    454: {
                    455:        struct bt463data *data = (struct bt463data *)rc;
                    456:        int count, index;
                    457:
                    458:        /* can't fail; parameters have already been checked. */
                    459:        count = cursorp->cmap.count;
                    460:        index = cursorp->cmap.index;
                    461:        copyin(cursorp->cmap.red, &data->curcmap_r[index], count);
                    462:        copyin(cursorp->cmap.green, &data->curcmap_g[index], count);
                    463:        copyin(cursorp->cmap.blue, &data->curcmap_b[index], count);
                    464:        data->changed |= DATA_CURCMAP_CHANGED;
                    465:        data->ramdac_sched_update(data->cookie, bt463_update);
                    466: }
                    467:
                    468: int
                    469: bt463_get_curcmap(rc, cursorp)
                    470:        struct ramdac_cookie *rc;
                    471:        struct wsdisplay_cursor *cursorp;
                    472: {
                    473:        struct bt463data *data = (struct bt463data *)rc;
                    474:        int error;
                    475:
                    476:        cursorp->cmap.index = 0;        /* DOCMAP */
                    477:        cursorp->cmap.count = 2;
                    478:        if (cursorp->cmap.red != NULL) {
                    479:                error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
                    480:                if (error)
                    481:                        return (error);
                    482:        }
                    483:        if (cursorp->cmap.green != NULL) {
                    484:                error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
                    485:                if (error)
                    486:                        return (error);
                    487:        }
                    488:        if (cursorp->cmap.blue != NULL) {
                    489:                error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
                    490:                if (error)
                    491:                        return (error);
                    492:        }
                    493:        return (0);
                    494: }
                    495:
                    496:
                    497: /*****************************************************************************/
                    498:
                    499: /*
                    500:  * Internal functions.
                    501:  */
                    502:
                    503: #ifdef BT463_DEBUG
                    504: int bt463_store(void *v)
                    505: {
                    506:        struct bt463data *data = (struct bt463data *)v;
                    507:
                    508:        data->changed = DATA_ALL_CHANGED;
                    509:        data->ramdac_sched_update(data->cookie, bt463_update);
                    510:        printf("Scheduled bt463 store\n");
                    511:
                    512:        return 0;
                    513: }
                    514:
                    515:
                    516: int bt463_readback(void *v)
                    517: {
                    518:        struct bt463data *data = (struct bt463data *)v;
                    519:
                    520:        data->ramdac_sched_update(data->cookie, bt463_copyback);
                    521:        printf("Scheduled bt463 copyback\n");
                    522:        return 0;
                    523: }
                    524:
                    525: int
                    526: bt463_debug(v)
                    527:        void *v;
                    528: {
                    529:        struct bt463data *data = (struct bt463data *)v;
                    530:        int i;
                    531:        u_int8_t val;
                    532:
                    533:        printf("BT463 main regs:\n");
                    534:        for (i = 0x200; i < 0x20F; i ++) {
                    535:          val = BTRREG(data, i);
                    536:          printf("  $%04x %02x\n", i, val);
                    537:        }
                    538:
                    539:        printf("BT463 revision register:\n");
                    540:          val = BTRREG(data, 0x220);
                    541:          printf("  $%04x %02x\n", 0x220, val);
                    542:
                    543:        printf("BT463 window type table (from softc):\n");
                    544:
                    545:        for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
                    546:          printf("%02x %06x\n", i, data->window_type[i]);
                    547:        }
                    548:
                    549:        return 0;
                    550: }
                    551:
                    552: void
                    553: bt463_copyback(p)
                    554:         void *p;
                    555: {
                    556:        struct bt463data *data = (struct bt463data *)p;
                    557:        int i;
                    558:
                    559:                for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
                    560:                        bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
                    561:                        data->window_type[i] = (BTRNREG(data) & 0xff);        /* B0-7   */
                    562:                        data->window_type[i] |= (BTRNREG(data) & 0xff) << 8;  /* B8-15  */
                    563:                        data->window_type[i] |= (BTRNREG(data) & 0xff) << 16; /* B16-23 */
                    564:                }
                    565: }
                    566: #endif
                    567:
                    568: inline void
                    569: bt463_wraddr(data, ireg)
                    570:        struct bt463data *data;
                    571:        u_int16_t ireg;
                    572: {
                    573:        data->ramdac_wr(data->cookie, BT463_REG_ADDR_LOW, ireg & 0xff);
                    574:        data->ramdac_wr(data->cookie, BT463_REG_ADDR_HIGH, (ireg >> 8) & 0xff);
                    575: }
                    576:
                    577: void
                    578: bt463_update(p)
                    579:        void *p;
                    580: {
                    581:        struct bt463data *data = (struct bt463data *)p;
                    582:        int i, v;
                    583:
                    584:        if (console_data != NULL) {
                    585:                /* The cookie passed in from sched_update is incorrect. Use the
                    586:                 * right one.
                    587:                 */
                    588:                data = console_data;
                    589:        }
                    590:
                    591:        v = data->changed;
                    592:
                    593:        /* The Bt463 won't accept window type data except during a blanking
                    594:         * interval, so we do this early in the interrupt.
                    595:         * Blanking the screen might also be a good idea, but it can cause
                    596:         * unpleasant flashing and is hard to do from this side of the
                    597:         * ramdac interface.
                    598:         */
                    599:        if (v & DATA_WTYPE_CHANGED) {
                    600:                /* spit out the window type data */
                    601:                for (i = 0; i < BT463_NWTYPE_ENTRIES; i++) {
                    602:                        bt463_wraddr(data, BT463_IREG_WINDOW_TYPE_TABLE + i);
                    603:                        BTWNREG(data, (data->window_type[i]) & 0xff);       /* B0-7   */
                    604:                        BTWNREG(data, (data->window_type[i] >> 8) & 0xff);  /* B8-15   */
                    605:                        BTWNREG(data, (data->window_type[i] >> 16) & 0xff); /* B16-23  */
                    606:                }
                    607:        }
                    608:
                    609:        if (v & DATA_CURCMAP_CHANGED) {
                    610:                bt463_wraddr(data, BT463_IREG_CURSOR_COLOR_0);
                    611:                /* spit out the cursor data */
                    612:                for (i = 0; i < 2; i++) {
                    613:                        BTWNREG(data, data->curcmap_r[i]);
                    614:                        BTWNREG(data, data->curcmap_g[i]);
                    615:                        BTWNREG(data, data->curcmap_b[i]);
                    616:                }
                    617:        }
                    618:
                    619:        if (v & DATA_CMAP_CHANGED) {
                    620:                bt463_wraddr(data, BT463_IREG_CPALETTE_RAM);
                    621:                /* spit out the colormap data */
                    622:                for (i = 0; i < BT463_NCMAP_ENTRIES; i++) {
                    623:                        data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
                    624:                                data->cmap_r[i]);
                    625:                        data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
                    626:                                data->cmap_g[i]);
                    627:                        data->ramdac_wr(data->cookie, BT463_REG_CMAP_DATA,
                    628:                                data->cmap_b[i]);
                    629:                }
                    630:        }
                    631:
                    632:        data->changed = 0;
                    633: }
                    634:
                    635: int    bt463_set_cursor (rc, cur)
                    636:        struct ramdac_cookie *rc;
                    637:        struct wsdisplay_cursor *cur;
                    638: {
                    639:        struct bt463data *data = (struct bt463data *)rc;
                    640:        return tga_builtin_set_cursor(data->cookie, cur);
                    641: }
                    642:
                    643: int    bt463_get_cursor (rc, cur)
                    644:        struct ramdac_cookie *rc;
                    645:        struct wsdisplay_cursor *cur;
                    646: {
                    647:        struct bt463data *data = (struct bt463data *)rc;
                    648:        return tga_builtin_get_cursor(data->cookie, cur);
                    649: }
                    650:
                    651: int    bt463_set_curpos (rc, cur)
                    652:        struct ramdac_cookie *rc;
                    653:        struct wsdisplay_curpos *cur;
                    654: {
                    655:        struct bt463data *data = (struct bt463data *)rc;
                    656:        return tga_builtin_set_curpos(data->cookie, cur);
                    657: }
                    658:
                    659: int    bt463_get_curpos (rc, cur)
                    660:        struct ramdac_cookie *rc;
                    661:        struct wsdisplay_curpos *cur;
                    662: {
                    663:        struct bt463data *data = (struct bt463data *)rc;
                    664:        return tga_builtin_get_curpos(data->cookie, cur);
                    665: }
                    666:
                    667: int    bt463_get_curmax (rc, cur)
                    668:        struct ramdac_cookie *rc;
                    669:        struct wsdisplay_curpos *cur;
                    670: {
                    671:        struct bt463data *data = (struct bt463data *)rc;
                    672:        return tga_builtin_get_curmax(data->cookie, cur);
                    673: }

CVSweb