2 * Copyright (c) 2003 Jake Burkholder.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/param.h>
31 #include <sys/systm.h>
33 #include <sys/consio.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
38 #include <machine/bus.h>
39 #include <machine/ofw_upa.h>
40 #include <machine/sc_machdep.h>
42 #include <dev/fb/fbreg.h>
43 #include <dev/fb/gallant12x22.h>
44 #include <dev/syscons/syscons.h>
46 #include <dev/ofw/openfirm.h>
48 #include <sparc64/creator/creator.h>
50 static int creator_configure(int flags);
52 static vi_probe_t creator_probe;
53 static vi_init_t creator_init;
54 static vi_get_info_t creator_get_info;
55 static vi_query_mode_t creator_query_mode;
56 static vi_set_mode_t creator_set_mode;
57 static vi_save_font_t creator_save_font;
58 static vi_load_font_t creator_load_font;
59 static vi_show_font_t creator_show_font;
60 static vi_save_palette_t creator_save_palette;
61 static vi_load_palette_t creator_load_palette;
62 static vi_set_border_t creator_set_border;
63 static vi_save_state_t creator_save_state;
64 static vi_load_state_t creator_load_state;
65 static vi_set_win_org_t creator_set_win_org;
66 static vi_read_hw_cursor_t creator_read_hw_cursor;
67 static vi_set_hw_cursor_t creator_set_hw_cursor;
68 static vi_set_hw_cursor_shape_t creator_set_hw_cursor_shape;
69 static vi_blank_display_t creator_blank_display;
70 static vi_mmap_t creator_mmap;
71 static vi_ioctl_t creator_ioctl;
72 static vi_clear_t creator_clear;
73 static vi_fill_rect_t creator_fill_rect;
74 static vi_bitblt_t creator_bitblt;
75 static vi_diag_t creator_diag;
76 static vi_save_cursor_palette_t creator_save_cursor_palette;
77 static vi_load_cursor_palette_t creator_load_cursor_palette;
78 static vi_copy_t creator_copy;
79 static vi_putp_t creator_putp;
80 static vi_putc_t creator_putc;
81 static vi_puts_t creator_puts;
82 static vi_putm_t creator_putm;
84 static void creator_cursor_enable(struct creator_softc *sc, int onoff);
85 static void creator_cursor_install(struct creator_softc *sc);
87 static video_switch_t creatorvidsw = {
88 .probe = creator_probe,
90 .get_info = creator_get_info,
91 .query_mode = creator_query_mode,
92 .set_mode = creator_set_mode,
93 .save_font = creator_save_font,
94 .load_font = creator_load_font,
95 .show_font = creator_show_font,
96 .save_palette = creator_save_palette,
97 .load_palette = creator_load_palette,
98 .set_border = creator_set_border,
99 .save_state = creator_save_state,
100 .load_state = creator_load_state,
101 .set_win_org = creator_set_win_org,
102 .read_hw_cursor = creator_read_hw_cursor,
103 .set_hw_cursor = creator_set_hw_cursor,
104 .set_hw_cursor_shape = creator_set_hw_cursor_shape,
105 .blank_display = creator_blank_display,
106 .mmap = creator_mmap,
107 .ioctl = creator_ioctl,
108 .clear = creator_clear,
109 .fill_rect = creator_fill_rect,
110 .bitblt = creator_bitblt,
111 NULL, /* XXX brain damage */
112 NULL, /* XXX brain damage */
113 .diag = creator_diag,
114 .save_cursor_palette = creator_save_cursor_palette,
115 .load_cursor_palette = creator_load_cursor_palette,
116 .copy = creator_copy,
117 .putp = creator_putp,
118 .putc = creator_putc,
119 .puts = creator_puts,
123 VIDEO_DRIVER(creator, creatorvidsw, creator_configure);
125 extern sc_rndr_sw_t txtrndrsw;
126 RENDERER(creator, 0, txtrndrsw, gfb_set);
128 RENDERER_MODULE(creator, gfb_set);
130 extern struct bus_space_tag nexus_bustag;
132 #define C(r, g, b) ((b << 16) | (g << 8) | (r))
133 static const int cmap[] = {
134 C(0x00, 0x00, 0x00), /* black */
135 C(0x00, 0x00, 0xff), /* blue */
136 C(0x00, 0xff, 0x00), /* green */
137 C(0x00, 0xc0, 0xc0), /* cyan */
138 C(0xff, 0x00, 0x00), /* red */
139 C(0xc0, 0x00, 0xc0), /* magenta */
140 C(0xc0, 0xc0, 0x00), /* brown */
141 C(0xc0, 0xc0, 0xc0), /* light grey */
142 C(0x80, 0x80, 0x80), /* dark grey */
143 C(0x80, 0x80, 0xff), /* light blue */
144 C(0x80, 0xff, 0x80), /* light green */
145 C(0x80, 0xff, 0xff), /* light cyan */
146 C(0xff, 0x80, 0x80), /* light red */
147 C(0xff, 0x80, 0xff), /* light magenta */
148 C(0xff, 0xff, 0x80), /* yellow */
149 C(0xff, 0xff, 0xff), /* white */
152 static const u_char creator_mouse_pointer[64][8] __aligned(8) = {
153 { 0x00, 0x00, }, /* ............ */
154 { 0x80, 0x00, }, /* *........... */
155 { 0xc0, 0x00, }, /* **.......... */
156 { 0xe0, 0x00, }, /* ***......... */
157 { 0xf0, 0x00, }, /* ****........ */
158 { 0xf8, 0x00, }, /* *****....... */
159 { 0xfc, 0x00, }, /* ******...... */
160 { 0xfe, 0x00, }, /* *******..... */
161 { 0xff, 0x00, }, /* ********.... */
162 { 0xff, 0x80, }, /* *********... */
163 { 0xfc, 0xc0, }, /* ******..**.. */
164 { 0xdc, 0x00, }, /* **.***...... */
165 { 0x8e, 0x00, }, /* *...***..... */
166 { 0x0e, 0x00, }, /* ....***..... */
167 { 0x07, 0x00, }, /* .....***.... */
168 { 0x04, 0x00, }, /* .....*...... */
169 { 0x00, 0x00, }, /* ............ */
170 { 0x00, 0x00, }, /* ............ */
171 { 0x00, 0x00, }, /* ............ */
172 { 0x00, 0x00, }, /* ............ */
173 { 0x00, 0x00, }, /* ............ */
174 { 0x00, 0x00, }, /* ............ */
177 static struct creator_softc creator_softc;
179 static inline void creator_ras_fifo_wait(struct creator_softc *sc, int n);
180 static inline void creator_ras_setfontinc(struct creator_softc *sc, int fontinc);
181 static inline void creator_ras_setfontw(struct creator_softc *sc, int fontw);
182 static inline void creator_ras_setbg(struct creator_softc *sc, int bg);
183 static inline void creator_ras_setfg(struct creator_softc *sc, int fg);
184 static inline void creator_ras_setpmask(struct creator_softc *sc, int pmask);
185 static inline void creator_ras_wait(struct creator_softc *sc);
188 creator_ras_wait(struct creator_softc *sc)
194 ucsr = FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR);
195 if ((ucsr & (FBC_UCSR_FB_BUSY | FBC_UCSR_RP_BUSY)) == 0)
197 r = ucsr & (FBC_UCSR_READ_ERR | FBC_UCSR_FIFO_OVFL);
199 FFB_WRITE(sc, FFB_FBC, FFB_FBC_UCSR, r);
204 creator_ras_fifo_wait(struct creator_softc *sc, int n)
208 cache = sc->sc_fifo_cache;
210 cache = (FFB_READ(sc, FFB_FBC, FFB_FBC_UCSR) &
211 FBC_UCSR_FIFO_MASK) - 8;
212 sc->sc_fifo_cache = cache - n;
216 creator_ras_setfontinc(struct creator_softc *sc, int fontinc)
219 if (fontinc == sc->sc_fontinc_cache)
221 sc->sc_fontinc_cache = fontinc;
222 creator_ras_fifo_wait(sc, 1);
223 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTINC, fontinc);
224 creator_ras_wait(sc);
228 creator_ras_setfontw(struct creator_softc *sc, int fontw)
231 if (fontw == sc->sc_fontw_cache)
233 sc->sc_fontw_cache = fontw;
234 creator_ras_fifo_wait(sc, 1);
235 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTW, fontw);
236 creator_ras_wait(sc);
240 creator_ras_setbg(struct creator_softc *sc, int bg)
243 if (bg == sc->sc_bg_cache)
245 sc->sc_bg_cache = bg;
246 creator_ras_fifo_wait(sc, 1);
247 FFB_WRITE(sc, FFB_FBC, FFB_FBC_BG, bg);
248 creator_ras_wait(sc);
252 creator_ras_setfg(struct creator_softc *sc, int fg)
255 if (fg == sc->sc_fg_cache)
257 sc->sc_fg_cache = fg;
258 creator_ras_fifo_wait(sc, 1);
259 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FG, fg);
260 creator_ras_wait(sc);
264 creator_ras_setpmask(struct creator_softc *sc, int pmask)
267 if (pmask == sc->sc_pmask_cache)
269 sc->sc_pmask_cache = pmask;
270 creator_ras_fifo_wait(sc, 1);
271 FFB_WRITE(sc, FFB_FBC, FFB_FBC_PMASK, pmask);
272 creator_ras_wait(sc);
276 creator_configure(int flags)
278 struct upa_regs reg[FFB_NREG];
279 struct creator_softc *sc;
287 * For the high-level console probing return the number of
288 * registered adapters.
290 if (!(flags & VIO_PROBE_ONLY)) {
291 for (i = 0; vid_find_adapter(CREATOR_DRIVER_NAME, i) >= 0; i++)
296 /* Low-level console probing and initialization. */
299 if (sc->sc_va.va_flags & V_ADP_REGISTERED)
302 if ((chosen = OF_finddevice("/chosen")) == -1)
304 if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
306 if ((output = OF_instance_to_package(stdout)) == -1)
308 if (OF_getprop(output, "name", buf, sizeof(buf)) == -1)
310 if (strcmp(buf, "SUNW,ffb") == 0 || strcmp(buf, "SUNW,afb") == 0) {
311 sc->sc_flags = CREATOR_CONSOLE;
312 if (strcmp(buf, "SUNW,afb") == 0)
313 sc->sc_flags |= CREATOR_AFB;
314 sc->sc_node = output;
318 if (OF_getprop(output, "reg", reg, sizeof(reg)) == -1)
320 for (i = 0; i < FFB_NREG; i++) {
321 sc->sc_bt[i] = &nexus_bustag;
322 sc->sc_bh[i] = UPA_REG_PHYS(reg + i);
325 if (creator_init(0, &sc->sc_va, 0) < 0)
329 /* Return number of found adapters. */
334 creator_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
341 creator_init(int unit, video_adapter_t *adp, int flags)
343 struct creator_softc *sc;
348 sc = (struct creator_softc *)adp;
351 vid_init_struct(adp, CREATOR_DRIVER_NAME, -1, unit);
353 if (OF_getprop(sc->sc_node, "height", &sc->sc_height,
354 sizeof(sc->sc_height)) == -1)
356 if (OF_getprop(sc->sc_node, "width", &sc->sc_width,
357 sizeof(sc->sc_width)) == -1)
359 if ((options = OF_finddevice("/options")) == -1)
361 if (OF_getprop(options, "screen-#rows", buf, sizeof(buf)) == -1)
363 vi->vi_height = strtol(buf, NULL, 10);
364 if (OF_getprop(options, "screen-#columns", buf, sizeof(buf)) == -1)
366 vi->vi_width = strtol(buf, NULL, 10);
369 vi->vi_flags = V_INFO_COLOR;
370 vi->vi_mem_model = V_INFO_MM_OTHER;
372 sc->sc_font = gallant12x22_data;
373 sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
374 sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight)) / 2;
376 creator_set_mode(adp, 0);
378 if (!(sc->sc_flags & CREATOR_AFB)) {
379 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_DID);
380 if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
381 FFB_DAC_CFG_DID_PNUM) >> 12) != 0x236e) {
382 sc->sc_flags |= CREATOR_PAC1;
383 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_UCTRL);
384 if (((FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE) &
385 FFB_DAC_UCTRL_MANREV) >> 8) <= 2)
386 sc->sc_flags |= CREATOR_CURINV;
390 creator_blank_display(adp, V_DISPLAY_ON);
394 * Setting V_ADP_MODECHANGE serves as hack so creator_set_mode()
395 * (which will invalidate our caches and restore our settings) is
396 * called when the X server shuts down. Otherwise screen corruption
397 * happens most of the time.
399 adp->va_flags |= V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_BORDER |
401 if (vid_register(adp) < 0)
403 adp->va_flags |= V_ADP_REGISTERED;
409 creator_get_info(video_adapter_t *adp, int mode, video_info_t *info)
412 bcopy(&adp->va_info, info, sizeof(*info));
417 creator_query_mode(video_adapter_t *adp, video_info_t *info)
424 creator_set_mode(video_adapter_t *adp, int mode)
426 struct creator_softc *sc;
428 sc = (struct creator_softc *)adp;
429 sc->sc_bg_cache = -1;
430 sc->sc_fg_cache = -1;
431 sc->sc_fontinc_cache = -1;
432 sc->sc_fontw_cache = -1;
433 sc->sc_pmask_cache = -1;
435 creator_ras_wait(sc);
436 sc->sc_fifo_cache = 0;
437 creator_ras_fifo_wait(sc, 2);
438 FFB_WRITE(sc, FFB_FBC, FFB_FBC_PPC, FBC_PPC_VCE_DIS |
439 FBC_PPC_TBE_OPAQUE | FBC_PPC_APE_DIS | FBC_PPC_CS_CONST);
440 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FBC, FFB_FBC_WB_A | FFB_FBC_RB_A |
441 FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF | FFB_FBC_RGBE_MASK);
446 creator_save_font(video_adapter_t *adp, int page, int size, int width,
447 u_char *data, int c, int count)
454 creator_load_font(video_adapter_t *adp, int page, int size, int width,
455 u_char *data, int c, int count)
462 creator_show_font(video_adapter_t *adp, int page)
469 creator_save_palette(video_adapter_t *adp, u_char *palette)
476 creator_load_palette(video_adapter_t *adp, u_char *palette)
483 creator_set_border(video_adapter_t *adp, int border)
485 struct creator_softc *sc;
487 sc = (struct creator_softc *)adp;
488 creator_fill_rect(adp, border, 0, 0, sc->sc_width, sc->sc_ymargin);
489 creator_fill_rect(adp, border, 0, sc->sc_height - sc->sc_ymargin,
490 sc->sc_width, sc->sc_ymargin);
491 creator_fill_rect(adp, border, 0, 0, sc->sc_xmargin, sc->sc_height);
492 creator_fill_rect(adp, border, sc->sc_width - sc->sc_xmargin, 0,
493 sc->sc_xmargin, sc->sc_height);
498 creator_save_state(video_adapter_t *adp, void *p, size_t size)
505 creator_load_state(video_adapter_t *adp, void *p)
512 creator_set_win_org(video_adapter_t *adp, off_t offset)
519 creator_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
528 creator_set_hw_cursor(video_adapter_t *adp, int col, int row)
535 creator_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
536 int celsize, int blink)
543 creator_blank_display(video_adapter_t *adp, int mode)
545 struct creator_softc *sc;
549 sc = (struct creator_softc *)adp;
550 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
551 v = FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
554 v &= ~(FFB_DAC_CFG_TGEN_VSD | FFB_DAC_CFG_TGEN_HSD);
555 v |= FFB_DAC_CFG_TGEN_VIDE;
557 case V_DISPLAY_BLANK:
558 v |= (FFB_DAC_CFG_TGEN_VSD | FFB_DAC_CFG_TGEN_HSD);
559 v &= ~FFB_DAC_CFG_TGEN_VIDE;
561 case V_DISPLAY_STAND_BY:
562 v &= ~FFB_DAC_CFG_TGEN_VSD;
563 v &= ~FFB_DAC_CFG_TGEN_VIDE;
565 case V_DISPLAY_SUSPEND:
566 v |= FFB_DAC_CFG_TGEN_VSD;
567 v &= ~FFB_DAC_CFG_TGEN_HSD;
568 v &= ~FFB_DAC_CFG_TGEN_VIDE;
571 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
572 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE, v);
573 for (i = 0; i < 10; i++) {
574 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE, FFB_DAC_CFG_TGEN);
575 (void)FFB_READ(sc, FFB_DAC, FFB_DAC_VALUE);
581 creator_mmap(video_adapter_t *adp, vm_offset_t offset, vm_paddr_t *paddr,
589 creator_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
591 struct creator_softc *sc;
592 struct fbcursor *fbc;
595 sc = (struct creator_softc *)adp;
598 fb = (struct fbtype *)data;
599 fb->fb_type = FBTYPE_CREATOR;
600 fb->fb_height = sc->sc_height;
601 fb->fb_width = sc->sc_width;
602 fb->fb_depth = fb->fb_cmsize = fb->fb_size = 0;
605 fbc = (struct fbcursor *)data;
606 if (fbc->set & FB_CUR_SETCUR && fbc->enable == 0) {
607 creator_cursor_enable(sc, 0);
608 sc->sc_flags &= ~CREATOR_CUREN;
614 return (fb_commonioctl(adp, cmd, data));
620 creator_clear(video_adapter_t *adp)
622 struct creator_softc *sc;
624 sc = (struct creator_softc *)adp;
625 creator_fill_rect(adp, (SC_NORM_ATTR >> 4) & 0xf, 0, 0, sc->sc_width,
631 creator_fill_rect(video_adapter_t *adp, int val, int x, int y, int cx, int cy)
633 struct creator_softc *sc;
635 sc = (struct creator_softc *)adp;
636 creator_ras_setpmask(sc, 0xffffffff);
637 creator_ras_fifo_wait(sc, 2);
638 FFB_WRITE(sc, FFB_FBC, FFB_FBC_ROP, FBC_ROP_NEW);
639 FFB_WRITE(sc, FFB_FBC, FFB_FBC_DRAWOP, FBC_DRAWOP_RECTANGLE);
640 creator_ras_setfg(sc, cmap[val & 0xf]);
642 * Note that at least the Elite3D cards are sensitive to the order
643 * of operations here.
645 creator_ras_fifo_wait(sc, 4);
646 FFB_WRITE(sc, FFB_FBC, FFB_FBC_BY, y);
647 FFB_WRITE(sc, FFB_FBC, FFB_FBC_BX, x);
648 FFB_WRITE(sc, FFB_FBC, FFB_FBC_BH, cy);
649 FFB_WRITE(sc, FFB_FBC, FFB_FBC_BW, cx);
650 creator_ras_wait(sc);
655 creator_bitblt(video_adapter_t *adp, ...)
662 creator_diag(video_adapter_t *adp, int level)
666 fb_dump_adp_info(adp->va_name, adp, level);
667 creator_get_info(adp, 0, &info);
668 fb_dump_mode_info(adp->va_name, adp, &info, level);
673 creator_save_cursor_palette(video_adapter_t *adp, u_char *palette)
680 creator_load_cursor_palette(video_adapter_t *adp, u_char *palette)
687 creator_copy(video_adapter_t *adp, vm_offset_t src, vm_offset_t dst, int n)
694 creator_putp(video_adapter_t *adp, vm_offset_t off, u_int32_t p, u_int32_t a,
695 int size, int bpp, int bit_ltor, int byte_ltor)
702 creator_putc(video_adapter_t *adp, vm_offset_t off, u_int8_t c, u_int8_t a)
704 struct creator_softc *sc;
710 sc = (struct creator_softc *)adp;
711 row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
712 col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
713 p = (uint16_t *)sc->sc_font + (c * adp->va_info.vi_cheight);
714 creator_ras_setfg(sc, cmap[a & 0xf]);
715 creator_ras_setbg(sc, cmap[(a >> 4) & 0xf]);
716 creator_ras_fifo_wait(sc, 1 + adp->va_info.vi_cheight);
717 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONTXY,
718 ((row + sc->sc_ymargin) << 16) | (col + sc->sc_xmargin));
719 creator_ras_setfontw(sc, adp->va_info.vi_cwidth);
720 creator_ras_setfontinc(sc, 0x10000);
721 for (i = 0; i < adp->va_info.vi_cheight; i++) {
722 FFB_WRITE(sc, FFB_FBC, FFB_FBC_FONT, *p++ << 16);
728 creator_puts(video_adapter_t *adp, vm_offset_t off, u_int16_t *s, int len)
732 for (i = 0; i < len; i++) {
733 (*vidsw[adp->va_index]->putc)(adp, off + i, s[i] & 0xff,
734 (s[i] & 0xff00) >> 8);
740 creator_putm(video_adapter_t *adp, int x, int y, u_int8_t *pixel_image,
741 u_int32_t pixel_mask, int size, int width)
743 struct creator_softc *sc;
745 sc = (struct creator_softc *)adp;
746 if (!(sc->sc_flags & CREATOR_CUREN)) {
747 creator_cursor_install(sc);
748 creator_cursor_enable(sc, 1);
749 sc->sc_flags |= CREATOR_CUREN;
751 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_POS);
752 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
753 ((y + sc->sc_ymargin) << 16) | (x + sc->sc_xmargin));
758 creator_cursor_enable(struct creator_softc *sc, int onoff)
762 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_CTRL);
763 if (sc->sc_flags & CREATOR_CURINV)
764 v = onoff ? FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1 : 0;
766 v = onoff ? 0 : FFB_DAC_CUR_CTRL_P0 | FFB_DAC_CUR_CTRL_P1;
767 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, v);
771 creator_cursor_install(struct creator_softc *sc)
775 creator_cursor_enable(sc, 0);
776 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2, FFB_DAC_CUR_COLOR1);
777 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0xffffff);
778 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2, 0x0);
779 for (i = 0; i < 2; i++) {
780 FFB_WRITE(sc, FFB_DAC, FFB_DAC_TYPE2,
781 i ? FFB_DAC_CUR_BITMAP_P0 : FFB_DAC_CUR_BITMAP_P1);
782 for (j = 0; j < 64; j++) {
783 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
784 *(const uint32_t *)(&creator_mouse_pointer[j][0]));
785 FFB_WRITE(sc, FFB_DAC, FFB_DAC_VALUE2,
786 *(const uint32_t *)(&creator_mouse_pointer[j][4]));