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

Annotation of sys/dev/ic/bt485.c, Revision 1.1

1.1     ! nbrk        1: /* $OpenBSD: bt485.c,v 1.12 2002/11/09 22:51:48 miod Exp $ */
        !             2: /* $NetBSD: bt485.c,v 1.2 2000/04/02 18:55:01 nathanw Exp $ */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Author: Chris G. Demetriou
        !             9:  *
        !            10:  * Permission to use, copy, modify and distribute this software and
        !            11:  * its documentation is hereby granted, provided that both the copyright
        !            12:  * notice and this permission notice appear in all copies of the
        !            13:  * software, derivative works or modified versions, and any portions
        !            14:  * thereof, and that both notices appear in supporting documentation.
        !            15:  *
        !            16:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            17:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
        !            18:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            19:  *
        !            20:  * Carnegie Mellon requests users of this software to return to
        !            21:  *
        !            22:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
        !            23:  *  School of Computer Science
        !            24:  *  Carnegie Mellon University
        !            25:  *  Pittsburgh PA 15213-3890
        !            26:  *
        !            27:  * any improvements or extensions that they make and grant Carnegie the
        !            28:  * rights to redistribute these changes.
        !            29:  */
        !            30:
        !            31:  /* This code was derived from and originally located in sys/dev/pci/
        !            32:   *     NetBSD: tga_bt485.c,v 1.4 1999/03/24 05:51:21 mrg Exp
        !            33:   */
        !            34:
        !            35: #include <sys/param.h>
        !            36: #include <sys/systm.h>
        !            37: #include <sys/device.h>
        !            38: #include <sys/buf.h>
        !            39: #include <sys/kernel.h>
        !            40: #include <sys/malloc.h>
        !            41:
        !            42: #include <uvm/uvm_extern.h>
        !            43:
        !            44: #include <dev/pci/pcivar.h>
        !            45: #include <dev/ic/bt485reg.h>
        !            46: #include <dev/ic/bt485var.h>
        !            47: #include <dev/ic/ramdac.h>
        !            48:
        !            49: #include <dev/wscons/wsconsio.h>
        !            50: #include <dev/wscons/wsdisplayvar.h>
        !            51: #include <dev/rasops/rasops.h>
        !            52:
        !            53: /*
        !            54:  * Functions exported via the RAMDAC configuration table.
        !            55:  */
        !            56: void   bt485_init(struct ramdac_cookie *);
        !            57: int    bt485_set_cmap(struct ramdac_cookie *,
        !            58:            struct wsdisplay_cmap *);
        !            59: int    bt485_get_cmap(struct ramdac_cookie *,
        !            60:            struct wsdisplay_cmap *);
        !            61: int    bt485_set_cursor(struct ramdac_cookie *,
        !            62:            struct wsdisplay_cursor *);
        !            63: int    bt485_get_cursor(struct ramdac_cookie *,
        !            64:            struct wsdisplay_cursor *);
        !            65: int    bt485_set_curpos(struct ramdac_cookie *,
        !            66:            struct wsdisplay_curpos *);
        !            67: int    bt485_get_curpos(struct ramdac_cookie *,
        !            68:            struct wsdisplay_curpos *);
        !            69: int    bt485_get_curmax(struct ramdac_cookie *,
        !            70:            struct wsdisplay_curpos *);
        !            71:
        !            72: /* XXX const */
        !            73: struct ramdac_funcs bt485_funcsstruct = {
        !            74:        "Bt485",
        !            75:        bt485_register,
        !            76:        bt485_init,
        !            77:        bt485_set_cmap,
        !            78:        bt485_get_cmap,
        !            79:        bt485_set_cursor,
        !            80:        bt485_get_cursor,
        !            81:        bt485_set_curpos,
        !            82:        bt485_get_curpos,
        !            83:        bt485_get_curmax,
        !            84:        NULL,                   /* check_curcmap; not needed */
        !            85:        NULL,                   /* set_curcmap; not needed */
        !            86:        NULL,                   /* get_curcmap; not needed */
        !            87:        NULL,                   /* no dot clock to set */
        !            88: };
        !            89:
        !            90: /*
        !            91:  * Private data.
        !            92:  */
        !            93: struct bt485data {
        !            94:        void            *cookie;        /* This is what is passed
        !            95:                                         * around, and is probably
        !            96:                                         * struct tga_devconfig *
        !            97:                                         */
        !            98:
        !            99:        int             (*ramdac_sched_update)(void *, void (*)(void *));
        !           100:        void            (*ramdac_wr)(void *, u_int, u_int8_t);
        !           101:        u_int8_t        (*ramdac_rd)(void *, u_int);
        !           102:
        !           103:        int     changed;                        /* what changed; see below */
        !           104:        int     curenb;                         /* cursor enabled */
        !           105:        struct wsdisplay_curpos curpos;         /* current cursor position */
        !           106:        struct wsdisplay_curpos curhot;         /* cursor hotspot */
        !           107:        char curcmap_r[2];                      /* cursor colormap */
        !           108:        char curcmap_g[2];
        !           109:        char curcmap_b[2];
        !           110:        struct wsdisplay_curpos cursize;        /* current cursor size */
        !           111:        char curimage[512];                     /* cursor image data */
        !           112:        char curmask[512];                      /* cursor mask data */
        !           113:        char cmap_r[256];                               /* colormap */
        !           114:        char cmap_g[256];
        !           115:        char cmap_b[256];
        !           116: };
        !           117:
        !           118: #define        DATA_ENB_CHANGED        0x01    /* cursor enable changed */
        !           119: #define        DATA_CURCMAP_CHANGED    0x02    /* cursor colormap changed */
        !           120: #define        DATA_CURSHAPE_CHANGED   0x04    /* cursor size, image, mask changed */
        !           121: #define        DATA_CMAP_CHANGED       0x08    /* colormap changed */
        !           122: #define        DATA_ALL_CHANGED        0x0f
        !           123:
        !           124: #define        CURSOR_MAX_SIZE         64
        !           125:
        !           126: /*
        !           127:  * Internal functions.
        !           128:  */
        !           129: inline void    bt485_wr_i(struct bt485data *, u_int8_t, u_int8_t);
        !           130: inline u_int8_t bt485_rd_i(struct bt485data *, u_int8_t);
        !           131: void   bt485_update(void *);
        !           132: void   bt485_update_curpos(struct bt485data *);
        !           133:
        !           134: /*****************************************************************************/
        !           135:
        !           136: /*
        !           137:  * Functions exported via the RAMDAC configuration table.
        !           138:  */
        !           139:
        !           140: struct ramdac_funcs *
        !           141: bt485_funcs(void)
        !           142: {
        !           143:        return &bt485_funcsstruct;
        !           144: }
        !           145:
        !           146: struct ramdac_cookie *
        !           147: bt485_register(v, sched_update, wr, rd)
        !           148:        void *v;
        !           149:        int (*sched_update)(void *, void (*)(void *));
        !           150:        void (*wr)(void *, u_int, u_int8_t);
        !           151:        u_int8_t (*rd)(void *, u_int);
        !           152: {
        !           153:        struct bt485data *data;
        !           154:        /*
        !           155:         * XXX -- comment out of date.  rcd.
        !           156:         * If we should allocate a new private info struct, do so.
        !           157:         * Otherwise, use the one we have (if it's there), or
        !           158:         * use the temporary one on the stack.
        !           159:         */
        !           160:        data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
        !           161:        /* XXX -- if !data */
        !           162:        data->cookie = v;
        !           163:        data->ramdac_sched_update = sched_update;
        !           164:        data->ramdac_wr = wr;
        !           165:        data->ramdac_rd = rd;
        !           166:        return (struct ramdac_cookie *)data;
        !           167: }
        !           168:
        !           169: /*
        !           170:  * This function exists solely to provide a means to init
        !           171:  * the RAMDAC without first registering.  It is useful for
        !           172:  * initializing the console early on.
        !           173:  */
        !           174: void
        !           175: bt485_cninit(v, sched_update, wr, rd)
        !           176:        void *v;
        !           177:        int (*sched_update)(void *, void (*)(void *));
        !           178:        void (*wr)(void *, u_int, u_int8_t);
        !           179:        u_int8_t (*rd)(void *, u_int);
        !           180: {
        !           181:        struct bt485data tmp, *data = &tmp;
        !           182:        data->cookie = v;
        !           183:        data->ramdac_sched_update = sched_update;
        !           184:        data->ramdac_wr = wr;
        !           185:        data->ramdac_rd = rd;
        !           186:        bt485_init((struct ramdac_cookie *)data);
        !           187: }
        !           188:
        !           189: void
        !           190: bt485_init(rc)
        !           191:        struct ramdac_cookie *rc;
        !           192: {
        !           193:        u_int8_t regval;
        !           194:        struct bt485data *data = (struct bt485data *)rc;
        !           195:        int i;
        !           196:
        !           197:        /*
        !           198:         * Init the BT485 for normal operation.
        !           199:         */
        !           200:
        !           201:        /*
        !           202:         * Allow indirect register access.  (Actually, this is
        !           203:         * already enabled.  In fact, if it is _disabled_, for
        !           204:         * some reason the monitor appears to lose sync!!! (?!?!)
        !           205:         */
        !           206:        regval = data->ramdac_rd(data->cookie, BT485_REG_COMMAND_0);
        !           207:        regval |= 0x80;
        !           208:        /*
        !           209:         * Set the RAMDAC to 8 bit resolution, rather than 6 bit
        !           210:         * resolution.
        !           211:         */
        !           212:        regval |= 0x02;
        !           213:        data->ramdac_wr(data->cookie, BT485_REG_COMMAND_0, regval);
        !           214:
        !           215:        /* Set the RAMDAC to 8BPP (no interestion options). */
        !           216:        data->ramdac_wr(data->cookie, BT485_REG_COMMAND_1, 0x40);
        !           217:
        !           218:        /* Disable the cursor (for now) */
        !           219:        regval = data->ramdac_rd(data->cookie, BT485_REG_COMMAND_2);
        !           220:        regval &= ~0x03;
        !           221:        regval |= 0x24;
        !           222:        data->ramdac_wr(data->cookie, BT485_REG_COMMAND_2, regval);
        !           223:
        !           224:        /* Use a 64x64x2 cursor */
        !           225:        regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
        !           226:        regval |= 0x04;
        !           227:        regval |= 0x08;
        !           228:        bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
        !           229:
        !           230:        /* Set the Pixel Mask to something useful */
        !           231:        data->ramdac_wr(data->cookie, BT485_REG_PIXMASK, 0xff);
        !           232:
        !           233:        /*
        !           234:         * Initalize the RAMDAC info struct to hold all of our
        !           235:         * data, and fill it in.
        !           236:         */
        !           237:        data->changed = DATA_ALL_CHANGED;
        !           238:
        !           239:        data->curenb = 0;                               /* cursor disabled */
        !           240:        data->curpos.x = data->curpos.y = 0;            /* right now at 0,0 */
        !           241:        data->curhot.x = data->curhot.y = 0;            /* hot spot at 0,0 */
        !           242:
        !           243:        /* initial cursor colormap: 0 is black, 1 is white */
        !           244:        data->curcmap_r[0] = data->curcmap_g[0] = data->curcmap_b[0] = 0;
        !           245:        data->curcmap_r[1] = data->curcmap_g[1] = data->curcmap_b[1] = 0xff;
        !           246:
        !           247:        /* initial cursor data: 64x64 block of white. */
        !           248:        data->cursize.x = data->cursize.y = 64;
        !           249:        for (i = 0; i < 512; i++)
        !           250:                data->curimage[i] = data->curmask[i] = 0xff;
        !           251:
        !           252:        /* Initial colormap: 0 is black, everything else is white */
        !           253:        data->cmap_r[0] = data->cmap_g[0] = data->cmap_b[0] = 0;
        !           254:        for (i = 0; i < 256; i++) {
        !           255:                data->cmap_r[i] = rasops_cmap[3*i + 0];
        !           256:                data->cmap_g[i] = rasops_cmap[3*i + 1];
        !           257:                data->cmap_b[i] = rasops_cmap[3*i + 2];
        !           258:        }
        !           259:
        !           260:        bt485_update((void *)data);
        !           261: }
        !           262:
        !           263: int
        !           264: bt485_set_cmap(rc, cmapp)
        !           265:        struct ramdac_cookie *rc;
        !           266:        struct wsdisplay_cmap *cmapp;
        !           267: {
        !           268:        struct bt485data *data = (struct bt485data *)rc;
        !           269:        u_int count, index;
        !           270:        int s, error;
        !           271:
        !           272: #ifdef DIAGNOSTIC
        !           273:        if (rc == NULL)
        !           274:                panic("bt485_set_cmap: rc");
        !           275:        if (cmapp == NULL)
        !           276:                panic("bt485_set_cmap: cmapp");
        !           277: #endif
        !           278:        index = cmapp->index;
        !           279:        count = cmapp->count;
        !           280:
        !           281:        if (index >= 256 || count > 256 - index)
        !           282:                return (EINVAL);
        !           283:
        !           284:        s = spltty();
        !           285:
        !           286:        if ((error = copyin(cmapp->red, &data->cmap_r[index], count)) != 0) {
        !           287:                splx(s);
        !           288:                return (error);
        !           289:        }
        !           290:        if ((error = copyin(cmapp->green, &data->cmap_g[index], count)) != 0) {
        !           291:                splx(s);
        !           292:                return (error);
        !           293:        }
        !           294:        if ((error = copyin(cmapp->blue, &data->cmap_b[index], count)) != 0) {
        !           295:                splx(s);
        !           296:                return (error);
        !           297:        }
        !           298:
        !           299:        data->changed |= DATA_CMAP_CHANGED;
        !           300:
        !           301:        data->ramdac_sched_update(data->cookie, bt485_update);
        !           302: #ifdef __alpha__
        !           303:        alpha_mb();
        !           304: #endif
        !           305:        splx(s);
        !           306:
        !           307:        return (0);
        !           308: }
        !           309:
        !           310: int
        !           311: bt485_get_cmap(rc, cmapp)
        !           312:        struct ramdac_cookie *rc;
        !           313:        struct wsdisplay_cmap *cmapp;
        !           314: {
        !           315:        struct bt485data *data = (struct bt485data *)rc;
        !           316:        u_int count, index;
        !           317:        int error;
        !           318:
        !           319:        if (cmapp->index >= 256 || cmapp->count > 256 - cmapp->index)
        !           320:                return (EINVAL);
        !           321:
        !           322:        count = cmapp->count;
        !           323:        index = cmapp->index;
        !           324:
        !           325:        error = copyout(&data->cmap_r[index], cmapp->red, count);
        !           326:        if (error)
        !           327:                return (error);
        !           328:        error = copyout(&data->cmap_g[index], cmapp->green, count);
        !           329:        if (error)
        !           330:                return (error);
        !           331:        error = copyout(&data->cmap_b[index], cmapp->blue, count);
        !           332:        return (error);
        !           333: }
        !           334:
        !           335: int
        !           336: bt485_set_cursor(rc, cursorp)
        !           337:        struct ramdac_cookie *rc;
        !           338:        struct wsdisplay_cursor *cursorp;
        !           339: {
        !           340:        struct bt485data *data = (struct bt485data *)rc;
        !           341:        u_int count, index;
        !           342:        int error;
        !           343:        int v, s;
        !           344:
        !           345:        v = cursorp->which;
        !           346:
        !           347:        /*
        !           348:         * For DOCMAP and DOSHAPE, verify that parameters are OK
        !           349:         * before we do anything that we can't recover from.
        !           350:         */
        !           351:        if (v & WSDISPLAY_CURSOR_DOCMAP) {
        !           352:                index = cursorp->cmap.index;
        !           353:                count = cursorp->cmap.count;
        !           354:                if (index >= 2 || count > 2 - index)
        !           355:                        return (EINVAL);
        !           356:        }
        !           357:        if (v & WSDISPLAY_CURSOR_DOSHAPE) {
        !           358:                if ((u_int)cursorp->size.x > CURSOR_MAX_SIZE ||
        !           359:                    (u_int)cursorp->size.y > CURSOR_MAX_SIZE)
        !           360:                        return (EINVAL);
        !           361:        }
        !           362:
        !           363:        if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOCUR)) {
        !           364:                if (v & WSDISPLAY_CURSOR_DOPOS)
        !           365:                        data->curpos = cursorp->pos;
        !           366:                if (v & WSDISPLAY_CURSOR_DOCUR)
        !           367:                        data->curhot = cursorp->hot;
        !           368:                bt485_update_curpos(data);
        !           369:        }
        !           370:
        !           371:        s = spltty();
        !           372:
        !           373:        /* Parameters are OK; perform the requested operations. */
        !           374:        if (v & WSDISPLAY_CURSOR_DOCUR) {
        !           375:                data->curenb = cursorp->enable;
        !           376:                data->changed |= DATA_ENB_CHANGED;
        !           377:        }
        !           378:        if (v & WSDISPLAY_CURSOR_DOCMAP) {
        !           379:                index = cursorp->cmap.index;
        !           380:                count = cursorp->cmap.count;
        !           381:                if ((error = copyin(cursorp->cmap.red,
        !           382:                    &data->curcmap_r[index], count)) != 0) {
        !           383:                        splx(s);
        !           384:                        return (error);
        !           385:                }
        !           386:                if ((error = copyin(cursorp->cmap.green,
        !           387:                    &data->curcmap_g[index], count)) != 0) {
        !           388:                        splx(s);
        !           389:                        return (error);
        !           390:                }
        !           391:                if ((error = copyin(cursorp->cmap.blue,
        !           392:                    &data->curcmap_b[index], count)) != 0) {
        !           393:                        splx(s);
        !           394:                        return (error);
        !           395:                }
        !           396:                data->changed |= DATA_CURCMAP_CHANGED;
        !           397:        }
        !           398:        if (v & WSDISPLAY_CURSOR_DOSHAPE) {
        !           399:                data->cursize = cursorp->size;
        !           400:                count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
        !           401:                bzero(data->curimage, sizeof data->curimage);
        !           402:                bzero(data->curmask, sizeof data->curmask);
        !           403:                if ((error = copyin(cursorp->image, data->curimage,
        !           404:                    count)) != 0) {
        !           405:                        splx(s);
        !           406:                        return (error);
        !           407:                }
        !           408:                if ((error = copyin(cursorp->mask, data->curmask,
        !           409:                    count)) != 0) {
        !           410:                        splx(s);
        !           411:                        return (error);
        !           412:                }
        !           413:                data->changed |= DATA_CURSHAPE_CHANGED;
        !           414:        }
        !           415:
        !           416:        if (data->changed)
        !           417:                data->ramdac_sched_update(data->cookie, bt485_update);
        !           418:        splx(s);
        !           419:
        !           420:        return (0);
        !           421: }
        !           422:
        !           423: int
        !           424: bt485_get_cursor(rc, cursorp)
        !           425:        struct ramdac_cookie *rc;
        !           426:        struct wsdisplay_cursor *cursorp;
        !           427: {
        !           428:        struct bt485data *data = (struct bt485data *)rc;
        !           429:        int error, count;
        !           430:
        !           431:        /* we return everything they want */
        !           432:        cursorp->which = WSDISPLAY_CURSOR_DOALL;
        !           433:
        !           434:        cursorp->enable = data->curenb; /* DOCUR */
        !           435:        cursorp->pos = data->curpos;    /* DOPOS */
        !           436:        cursorp->hot = data->curhot;    /* DOHOT */
        !           437:
        !           438:        cursorp->cmap.index = 0;        /* DOCMAP */
        !           439:        cursorp->cmap.count = 2;
        !           440:        if (cursorp->cmap.red != NULL) {
        !           441:                error = copyout(data->curcmap_r, cursorp->cmap.red, 2);
        !           442:                if (error)
        !           443:                        return (error);
        !           444:        }
        !           445:        if (cursorp->cmap.green != NULL) {
        !           446:                error = copyout(data->curcmap_g, cursorp->cmap.green, 2);
        !           447:                if (error)
        !           448:                        return (error);
        !           449:        }
        !           450:        if (cursorp->cmap.blue != NULL) {
        !           451:                error = copyout(data->curcmap_b, cursorp->cmap.blue, 2);
        !           452:                if (error)
        !           453:                        return (error);
        !           454:        }
        !           455:
        !           456:        cursorp->size = data->cursize;  /* DOSHAPE */
        !           457:        if (cursorp->image != NULL) {
        !           458:                count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
        !           459:                error = copyout(data->curimage, cursorp->image, count);
        !           460:                if (error)
        !           461:                        return (error);
        !           462:                error = copyout(data->curmask, cursorp->mask, count);
        !           463:                if (error)
        !           464:                        return (error);
        !           465:        }
        !           466:
        !           467:        return (0);
        !           468: }
        !           469:
        !           470: int
        !           471: bt485_set_curpos(rc, curposp)
        !           472:        struct ramdac_cookie *rc;
        !           473:        struct wsdisplay_curpos *curposp;
        !           474: {
        !           475:        struct bt485data *data = (struct bt485data *)rc;
        !           476:
        !           477:        data->curpos = *curposp;
        !           478:        bt485_update_curpos(data);
        !           479:
        !           480:        return (0);
        !           481: }
        !           482:
        !           483: int
        !           484: bt485_get_curpos(rc, curposp)
        !           485:        struct ramdac_cookie *rc;
        !           486:        struct wsdisplay_curpos *curposp;
        !           487: {
        !           488:        struct bt485data *data = (struct bt485data *)rc;
        !           489:
        !           490:        *curposp = data->curpos;
        !           491:        return (0);
        !           492: }
        !           493:
        !           494: int
        !           495: bt485_get_curmax(rc, curposp)
        !           496:        struct ramdac_cookie *rc;
        !           497:        struct wsdisplay_curpos *curposp;
        !           498: {
        !           499:
        !           500:        curposp->x = curposp->y = CURSOR_MAX_SIZE;
        !           501:        return (0);
        !           502: }
        !           503:
        !           504: /*****************************************************************************/
        !           505:
        !           506: /*
        !           507:  * Internal functions.
        !           508:  */
        !           509:
        !           510: inline void
        !           511: bt485_wr_i(data, ireg, val)
        !           512:        struct bt485data *data;
        !           513:        u_int8_t ireg;
        !           514:        u_int8_t val;
        !           515: {
        !           516:        data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, ireg);
        !           517:        data->ramdac_wr(data->cookie, BT485_REG_EXTENDED, val);
        !           518: }
        !           519:
        !           520: inline u_int8_t
        !           521: bt485_rd_i(data, ireg)
        !           522:        struct bt485data *data;
        !           523:        u_int8_t ireg;
        !           524: {
        !           525:        data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, ireg);
        !           526:        return (data->ramdac_rd(data->cookie, BT485_REG_EXTENDED));
        !           527: }
        !           528:
        !           529: void
        !           530: bt485_update(vp)
        !           531:        void *vp;
        !           532: {
        !           533:        struct bt485data *data = vp;
        !           534:        u_int8_t regval;
        !           535:        int count, i, v;
        !           536:
        !           537:        v = data->changed;
        !           538:        data->changed = 0;
        !           539:
        !           540:        if (v & DATA_ENB_CHANGED) {
        !           541:                regval = data->ramdac_rd(data->cookie, BT485_REG_COMMAND_2);
        !           542:                if (data->curenb)
        !           543:                        regval |= 0x01;
        !           544:                else
        !           545:                        regval &= ~0x03;
        !           546:                 data->ramdac_wr(data->cookie, BT485_REG_COMMAND_2, regval);
        !           547:        }
        !           548:
        !           549:        if (v & DATA_CURCMAP_CHANGED) {
        !           550:                /* addr[9:0] assumed to be 0 */
        !           551:                /* set addr[7:0] to 1 */
        !           552:                 data->ramdac_wr(data->cookie, BT485_REG_COC_WRADDR, 0x01);
        !           553:
        !           554:                /* spit out the cursor data */
        !           555:                for (i = 0; i < 2; i++) {
        !           556:                        data->ramdac_wr(data->cookie, BT485_REG_COCDATA,
        !           557:                            data->curcmap_r[i]);
        !           558:                        data->ramdac_wr(data->cookie, BT485_REG_COCDATA,
        !           559:                            data->curcmap_g[i]);
        !           560:                        data->ramdac_wr(data->cookie, BT485_REG_COCDATA,
        !           561:                            data->curcmap_b[i]);
        !           562:                }
        !           563:        }
        !           564:
        !           565:        if (v & DATA_CURSHAPE_CHANGED) {
        !           566:                count = (CURSOR_MAX_SIZE / NBBY) * data->cursize.y;
        !           567:
        !           568:                /*
        !           569:                 * Write the cursor image data:
        !           570:                 *      set addr[9:8] to 0,
        !           571:                 *      set addr[7:0] to 0,
        !           572:                 *      spit it all out.
        !           573:                 */
        !           574:                regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
        !           575:                regval &= ~0x03;
        !           576:                bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
        !           577:                 data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, 0);
        !           578:                for (i = 0; i < count; i++)
        !           579:                        data->ramdac_wr(data->cookie, BT485_REG_CURSOR_RAM,
        !           580:                            data->curimage[i]);
        !           581:
        !           582:                /*
        !           583:                 * Write the cursor mask data:
        !           584:                 *      set addr[9:8] to 2,
        !           585:                 *      set addr[7:0] to 0,
        !           586:                 *      spit it all out.
        !           587:                 */
        !           588:                regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
        !           589:                regval &= ~0x03; regval |= 0x02;
        !           590:                bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
        !           591:                 data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, 0);
        !           592:                for (i = 0; i < count; i++)
        !           593:                        data->ramdac_wr(data->cookie, BT485_REG_CURSOR_RAM,
        !           594:                            data->curmask[i]);
        !           595:
        !           596:                /* set addr[9:0] back to 0 */
        !           597:                regval = bt485_rd_i(data, BT485_IREG_COMMAND_3);
        !           598:                regval &= ~0x03;
        !           599:                bt485_wr_i(data, BT485_IREG_COMMAND_3, regval);
        !           600:        }
        !           601:
        !           602:        if (v & DATA_CMAP_CHANGED) {
        !           603:                /* addr[9:0] assumed to be 0 */
        !           604:                /* set addr[7:0] to 0 */
        !           605:                 data->ramdac_wr(data->cookie, BT485_REG_PCRAM_WRADDR, 0x00);
        !           606:
        !           607:                /* spit out the cursor data */
        !           608:                for (i = 0; i < 256; i++) {
        !           609:                        data->ramdac_wr(data->cookie, BT485_REG_PALETTE,
        !           610:                            data->cmap_r[i]);
        !           611:                        data->ramdac_wr(data->cookie, BT485_REG_PALETTE,
        !           612:                            data->cmap_g[i]);
        !           613:                        data->ramdac_wr(data->cookie, BT485_REG_PALETTE,
        !           614:                            data->cmap_b[i]);
        !           615:                }
        !           616:        }
        !           617: }
        !           618:
        !           619: void
        !           620: bt485_update_curpos(data)
        !           621:        struct bt485data *data;
        !           622: {
        !           623:        void *cookie = data->cookie;
        !           624:        int s, x, y;
        !           625:
        !           626:        s = spltty();
        !           627:
        !           628:        x = data->curpos.x + CURSOR_MAX_SIZE - data->curhot.x;
        !           629:        y = data->curpos.y + CURSOR_MAX_SIZE - data->curhot.y;
        !           630:        data->ramdac_wr(cookie, BT485_REG_CURSOR_X_LOW, x & 0xff);
        !           631:        data->ramdac_wr(cookie, BT485_REG_CURSOR_X_HIGH, (x >> 8) & 0x0f);
        !           632:        data->ramdac_wr(cookie, BT485_REG_CURSOR_Y_LOW, y & 0xff);
        !           633:        data->ramdac_wr(cookie, BT485_REG_CURSOR_Y_HIGH, (y >> 8) & 0x0f);
        !           634:
        !           635:        splx(s);
        !           636: }

CVSweb