| @@ -1,21 +1,21 @@ | | | @@ -1,21 +1,21 @@ |
1 | /* $NetBSD: tcx.c,v 1.32 2009/08/06 18:26:03 macallan Exp $ */ | | 1 | /* $NetBSD: tcx.c,v 1.33 2009/08/18 20:45:42 macallan Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996,1998 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996,1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Paul Kranenburg. | | 8 | * by Paul Kranenburg and Michael Lorenz. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * | | 18 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * color display (TCX) driver. | | 33 | * color display (TCX) driver. |
34 | * | | 34 | * |
35 | * Does not handle interrupts, even though they can occur. | | 35 | * Does not handle interrupts, even though they can occur. |
36 | * | | 36 | * |
37 | * XXX should defer colormap updates to vertical retrace interrupts | | 37 | * XXX should defer colormap updates to vertical retrace interrupts |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #include <sys/cdefs.h> | | 40 | #include <sys/cdefs.h> |
41 | __KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.32 2009/08/06 18:26:03 macallan Exp $"); | | 41 | __KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.33 2009/08/18 20:45:42 macallan Exp $"); |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * define for cg8 emulation on S24 (24-bit version of tcx) for the SS5; | | 44 | * define for cg8 emulation on S24 (24-bit version of tcx) for the SS5; |
45 | * it is bypassed on the 8-bit version (onboard framebuffer for SS4) | | 45 | * it is bypassed on the 8-bit version (onboard framebuffer for SS4) |
46 | */ | | 46 | */ |
47 | #undef TCX_CG8 | | 47 | #undef TCX_CG8 |
48 | | | 48 | |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | #include <sys/systm.h> | | 50 | #include <sys/systm.h> |
51 | #include <sys/buf.h> | | 51 | #include <sys/buf.h> |
52 | #include <sys/device.h> | | 52 | #include <sys/device.h> |
53 | #include <sys/ioctl.h> | | 53 | #include <sys/ioctl.h> |
54 | #include <sys/malloc.h> | | 54 | #include <sys/malloc.h> |
| @@ -73,27 +73,27 @@ __KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.32 | | | @@ -73,27 +73,27 @@ __KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.32 |
73 | #include <dev/sbus/tcxreg.h> | | 73 | #include <dev/sbus/tcxreg.h> |
74 | | | 74 | |
75 | #include <dev/wscons/wsdisplayvar.h> | | 75 | #include <dev/wscons/wsdisplayvar.h> |
76 | #include <dev/wscons/wsconsio.h> | | 76 | #include <dev/wscons/wsconsio.h> |
77 | #include <dev/wsfont/wsfont.h> | | 77 | #include <dev/wsfont/wsfont.h> |
78 | #include <dev/rasops/rasops.h> | | 78 | #include <dev/rasops/rasops.h> |
79 | | | 79 | |
80 | #include <dev/wscons/wsdisplay_vconsvar.h> | | 80 | #include <dev/wscons/wsdisplay_vconsvar.h> |
81 | | | 81 | |
82 | #include "opt_wsemul.h" | | 82 | #include "opt_wsemul.h" |
83 | | | 83 | |
84 | /* per-display variables */ | | 84 | /* per-display variables */ |
85 | struct tcx_softc { | | 85 | struct tcx_softc { |
86 | struct device sc_dev; /* base device */ | | 86 | device_t sc_dev; /* base device */ |
87 | struct sbusdev sc_sd; /* sbus device */ | | 87 | struct sbusdev sc_sd; /* sbus device */ |
88 | struct fbdevice sc_fb; /* frame buffer device */ | | 88 | struct fbdevice sc_fb; /* frame buffer device */ |
89 | bus_space_tag_t sc_bustag; | | 89 | bus_space_tag_t sc_bustag; |
90 | struct openprom_addr sc_physadr[TCX_NREG];/* phys addr of h/w */ | | 90 | struct openprom_addr sc_physadr[TCX_NREG];/* phys addr of h/w */ |
91 | | | 91 | |
92 | bus_space_handle_t sc_bt; /* Brooktree registers */ | | 92 | bus_space_handle_t sc_bt; /* Brooktree registers */ |
93 | bus_space_handle_t sc_thc; /* THC registers */ | | 93 | bus_space_handle_t sc_thc; /* THC registers */ |
94 | uint8_t *sc_fbaddr; /* framebuffer */ | | 94 | uint8_t *sc_fbaddr; /* framebuffer */ |
95 | uint64_t *sc_rblit; /* blitspace */ | | 95 | uint64_t *sc_rblit; /* blitspace */ |
96 | uint64_t *sc_rstip; /* stipple space */ | | 96 | uint64_t *sc_rstip; /* stipple space */ |
97 | | | 97 | |
98 | short sc_8bit; /* true if 8-bit hardware */ | | 98 | short sc_8bit; /* true if 8-bit hardware */ |
99 | short sc_blanked; /* true if blanked */ | | 99 | short sc_blanked; /* true if blanked */ |
| @@ -136,27 +136,27 @@ struct wsscreen_list tcx_screenlist = { | | | @@ -136,27 +136,27 @@ struct wsscreen_list tcx_screenlist = { |
136 | * 8 bits per pixel, unpadded; writes to this space do not modify the | | 136 | * 8 bits per pixel, unpadded; writes to this space do not modify the |
137 | * other 18 bits. | | 137 | * other 18 bits. |
138 | */ | | 138 | */ |
139 | #define TCX_CTL_8_MAPPED 0x00000000 /* 8 bits, uses color map */ | | 139 | #define TCX_CTL_8_MAPPED 0x00000000 /* 8 bits, uses color map */ |
140 | #define TCX_CTL_24_MAPPED 0x01000000 /* 24 bits, uses color map */ | | 140 | #define TCX_CTL_24_MAPPED 0x01000000 /* 24 bits, uses color map */ |
141 | #define TCX_CTL_24_LEVEL 0x03000000 /* 24 bits, ignores color map */ | | 141 | #define TCX_CTL_24_LEVEL 0x03000000 /* 24 bits, ignores color map */ |
142 | #define TCX_CTL_PIXELMASK 0x00FFFFFF /* mask for index/level */ | | 142 | #define TCX_CTL_PIXELMASK 0x00FFFFFF /* mask for index/level */ |
143 | | | 143 | |
144 | /* autoconfiguration driver */ | | 144 | /* autoconfiguration driver */ |
145 | static void tcxattach(device_t, device_t, void *); | | 145 | static void tcxattach(device_t, device_t, void *); |
146 | static int tcxmatch(device_t, cfdata_t, void *); | | 146 | static int tcxmatch(device_t, cfdata_t, void *); |
147 | static void tcx_unblank(device_t); | | 147 | static void tcx_unblank(device_t); |
148 | | | 148 | |
149 | CFATTACH_DECL(tcx, sizeof(struct tcx_softc), | | 149 | CFATTACH_DECL_NEW(tcx, sizeof(struct tcx_softc), |
150 | tcxmatch, tcxattach, NULL, NULL); | | 150 | tcxmatch, tcxattach, NULL, NULL); |
151 | | | 151 | |
152 | extern struct cfdriver tcx_cd; | | 152 | extern struct cfdriver tcx_cd; |
153 | | | 153 | |
154 | dev_type_open(tcxopen); | | 154 | dev_type_open(tcxopen); |
155 | dev_type_close(tcxclose); | | 155 | dev_type_close(tcxclose); |
156 | dev_type_ioctl(tcxioctl); | | 156 | dev_type_ioctl(tcxioctl); |
157 | dev_type_mmap(tcxmmap); | | 157 | dev_type_mmap(tcxmmap); |
158 | | | 158 | |
159 | const struct cdevsw tcx_cdevsw = { | | 159 | const struct cdevsw tcx_cdevsw = { |
160 | tcxopen, tcxclose, noread, nowrite, tcxioctl, | | 160 | tcxopen, tcxclose, noread, nowrite, tcxioctl, |
161 | nostop, notty, nopoll, tcxmmap, nokqfilter, | | 161 | nostop, notty, nopoll, tcxmmap, nokqfilter, |
162 | }; | | 162 | }; |
| @@ -223,33 +223,34 @@ void | | | @@ -223,33 +223,34 @@ void |
223 | tcxattach(device_t parent, device_t self, void *args) | | 223 | tcxattach(device_t parent, device_t self, void *args) |
224 | { | | 224 | { |
225 | struct tcx_softc *sc = device_private(self); | | 225 | struct tcx_softc *sc = device_private(self); |
226 | struct sbus_attach_args *sa = args; | | 226 | struct sbus_attach_args *sa = args; |
227 | struct wsemuldisplaydev_attach_args aa; | | 227 | struct wsemuldisplaydev_attach_args aa; |
228 | struct rasops_info *ri; | | 228 | struct rasops_info *ri; |
229 | unsigned long defattr; | | 229 | unsigned long defattr; |
230 | int node, ramsize; | | 230 | int node, ramsize; |
231 | struct fbdevice *fb = &sc->sc_fb; | | 231 | struct fbdevice *fb = &sc->sc_fb; |
232 | bus_space_handle_t bh; | | 232 | bus_space_handle_t bh; |
233 | int isconsole, i, j; | | 233 | int isconsole, i, j; |
234 | uint32_t confreg; | | 234 | uint32_t confreg; |
235 | | | 235 | |
| | | 236 | sc->sc_dev = self; |
236 | sc->sc_bustag = sa->sa_bustag; | | 237 | sc->sc_bustag = sa->sa_bustag; |
237 | node = sa->sa_node; | | 238 | node = sa->sa_node; |
238 | | | 239 | |
239 | fb->fb_driver = &tcx_fbdriver; | | 240 | fb->fb_driver = &tcx_fbdriver; |
240 | fb->fb_device = &sc->sc_dev; | | 241 | fb->fb_device = sc->sc_dev; |
241 | /* Mask out invalid flags from the user. */ | | 242 | /* Mask out invalid flags from the user. */ |
242 | fb->fb_flags = device_cfdata(&sc->sc_dev)->cf_flags & FB_USERMASK; | | 243 | fb->fb_flags = device_cfdata(sc->sc_dev)->cf_flags & FB_USERMASK; |
243 | /* | | 244 | /* |
244 | * The onboard framebuffer on the SS4 supports only 8-bit mode; | | 245 | * The onboard framebuffer on the SS4 supports only 8-bit mode; |
245 | * it can be distinguished from the S24 card for the SS5 by the | | 246 | * it can be distinguished from the S24 card for the SS5 by the |
246 | * presence of the "tcx-8-bit" attribute on the SS4 version. | | 247 | * presence of the "tcx-8-bit" attribute on the SS4 version. |
247 | */ | | 248 | */ |
248 | sc->sc_8bit = node_has_property(node, "tcx-8-bit"); | | 249 | sc->sc_8bit = node_has_property(node, "tcx-8-bit"); |
249 | fb->fb_type.fb_depth = 8; | | 250 | fb->fb_type.fb_depth = 8; |
250 | fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node); | | 251 | fb_setsize_obp(fb, fb->fb_type.fb_depth, 1152, 900, node); |
251 | | | 252 | |
252 | if (sc->sc_8bit) { | | 253 | if (sc->sc_8bit) { |
253 | printf(" {8bit only TCX)"); | | 254 | printf(" {8bit only TCX)"); |
254 | ramsize = 1024 * 1024; | | 255 | ramsize = 1024 * 1024; |
255 | /* XXX - fix THC and TEC offsets */ | | 256 | /* XXX - fix THC and TEC offsets */ |
| @@ -355,31 +356,27 @@ tcxattach(device_t parent, device_t self | | | @@ -355,31 +356,27 @@ tcxattach(device_t parent, device_t self |
355 | } | | 356 | } |
356 | tcx_loadcmap(sc, 0, 256); | | 357 | tcx_loadcmap(sc, 0, 256); |
357 | | | 358 | |
358 | /* enable video */ | | 359 | /* enable video */ |
359 | confreg = bus_space_read_4(sa->sa_bustag, sc->sc_thc, THC_MISC); | | 360 | confreg = bus_space_read_4(sa->sa_bustag, sc->sc_thc, THC_MISC); |
360 | confreg |= THC_MISC_VIDEN; | | 361 | confreg |= THC_MISC_VIDEN; |
361 | bus_space_write_4(sa->sa_bustag, sc->sc_thc, THC_MISC, confreg); | | 362 | bus_space_write_4(sa->sa_bustag, sc->sc_thc, THC_MISC, confreg); |
362 | | | 363 | |
363 | if (isconsole) { | | 364 | if (isconsole) { |
364 | printf(" (console)\n"); | | 365 | printf(" (console)\n"); |
365 | } else | | 366 | } else |
366 | printf("\n"); | | 367 | printf("\n"); |
367 | | | 368 | |
368 | bus_space_write_4(sa->sa_bustag, sc->sc_bt, DAC_ADDRESS, 0); | | 369 | sbus_establish(&sc->sc_sd, sc->sc_dev); |
369 | printf("DAC ID: %02x %02x\n", | | | |
370 | bus_space_read_1(sa->sa_bustag, sc->sc_bt, DAC_CONTROL_1), | | | |
371 | bus_space_read_1(sa->sa_bustag, sc->sc_bt, DAC_CONTROL_1)); | | | |
372 | sbus_establish(&sc->sc_sd, &sc->sc_dev); | | | |
373 | fb_attach(&sc->sc_fb, isconsole); | | 370 | fb_attach(&sc->sc_fb, isconsole); |
374 | | | 371 | |
375 | sc->sc_mode = WSDISPLAYIO_MODE_EMUL; | | 372 | sc->sc_mode = WSDISPLAYIO_MODE_EMUL; |
376 | wsfont_init(); | | 373 | wsfont_init(); |
377 | | | 374 | |
378 | vcons_init(&sc->vd, sc, &tcx_defscreendesc, &tcx_accessops); | | 375 | vcons_init(&sc->vd, sc, &tcx_defscreendesc, &tcx_accessops); |
379 | sc->vd.init_screen = tcx_init_screen; | | 376 | sc->vd.init_screen = tcx_init_screen; |
380 | | | 377 | |
381 | vcons_init_screen(&sc->vd, &tcx_console_screen, 1, &defattr); | | 378 | vcons_init_screen(&sc->vd, &tcx_console_screen, 1, &defattr); |
382 | tcx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; | | 379 | tcx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; |
383 | | | 380 | |
384 | sc->sc_bg = (defattr >> 16) & 0xff; | | 381 | sc->sc_bg = (defattr >> 16) & 0xff; |
385 | tcx_clearscreen(sc); | | 382 | tcx_clearscreen(sc); |
| @@ -532,27 +529,27 @@ tcxioctl(dev_t dev, u_long cmd, void *da | | | @@ -532,27 +529,27 @@ tcxioctl(dev_t dev, u_long cmd, void *da |
532 | return (error); | | 529 | return (error); |
533 | /* now blast them into the chip */ | | 530 | /* now blast them into the chip */ |
534 | /* XXX should use retrace interrupt */ | | 531 | /* XXX should use retrace interrupt */ |
535 | tcx_loadcmap(sc, p->index, p->count); | | 532 | tcx_loadcmap(sc, p->index, p->count); |
536 | #undef p | | 533 | #undef p |
537 | break; | | 534 | break; |
538 | #endif | | 535 | #endif |
539 | case FBIOGVIDEO: | | 536 | case FBIOGVIDEO: |
540 | *(int *)data = sc->sc_blanked; | | 537 | *(int *)data = sc->sc_blanked; |
541 | break; | | 538 | break; |
542 | | | 539 | |
543 | case FBIOSVIDEO: | | 540 | case FBIOSVIDEO: |
544 | if (*(int *)data) | | 541 | if (*(int *)data) |
545 | tcx_unblank(&sc->sc_dev); | | 542 | tcx_unblank(sc->sc_dev); |
546 | else if (!sc->sc_blanked) { | | 543 | else if (!sc->sc_blanked) { |
547 | sc->sc_blanked = 1; | | 544 | sc->sc_blanked = 1; |
548 | //sc->sc_thc->thc_hcmisc &= ~THC_MISC_VIDEN; | | 545 | //sc->sc_thc->thc_hcmisc &= ~THC_MISC_VIDEN; |
549 | /* Put monitor in `power-saving mode' */ | | 546 | /* Put monitor in `power-saving mode' */ |
550 | //sc->sc_thc->thc_hcmisc |= THC_MISC_VSYNC_DISABLE; | | 547 | //sc->sc_thc->thc_hcmisc |= THC_MISC_VSYNC_DISABLE; |
551 | //sc->sc_thc->thc_hcmisc |= THC_MISC_HSYNC_DISABLE; | | 548 | //sc->sc_thc->thc_hcmisc |= THC_MISC_HSYNC_DISABLE; |
552 | } | | 549 | } |
553 | break; | | 550 | break; |
554 | | | 551 | |
555 | default: | | 552 | default: |
556 | #ifdef DEBUG | | 553 | #ifdef DEBUG |
557 | log(LOG_NOTICE, "tcxioctl(0x%lx) (%s[%d])\n", cmd, | | 554 | log(LOG_NOTICE, "tcxioctl(0x%lx) (%s[%d])\n", cmd, |
558 | l->l_proc->p_comm, l->l_proc->p_pid); | | 555 | l->l_proc->p_comm, l->l_proc->p_pid); |