pvr.c revision 1.12 1 /* $NetBSD: pvr.c,v 1.12 2002/05/03 04:42:08 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 2001 Marcus Comstedt.
5 * Copyright (c) 2001 Jason R. Thorpe.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Marcus Comstedt.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /*
37 * Copyright (c) 1998, 1999 Tohru Nishimura. All rights reserved.
38 *
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
41 * are met:
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by Tohru Nishimura
50 * for the NetBSD Project.
51 * 4. The name of the author may not be used to endorse or promote products
52 * derived from this software without specific prior written permission
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
55 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
56 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
58 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
63 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 */
65
66 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
67
68 __KERNEL_RCSID(0, "$NetBSD: pvr.c,v 1.12 2002/05/03 04:42:08 thorpej Exp $");
69
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/kernel.h>
73 #include <sys/device.h>
74 #include <sys/malloc.h>
75 #include <sys/buf.h>
76 #include <sys/ioctl.h>
77
78 #include <machine/vmparam.h>
79 #include <machine/cpu.h>
80 #include <machine/bus.h>
81
82 #include <dev/cons.h>
83
84 #include <dev/wscons/wsconsio.h>
85 #include <dev/wscons/wsdisplayvar.h>
86
87 #include <dev/wscons/wscons_callbacks.h>
88
89 #include <dev/rasops/rasops.h>
90 #include <dev/wsfont/wsfont.h>
91
92 #include <dreamcast/dev/pvrvar.h>
93 #include <dreamcast/dev/maple/mkbdvar.h>
94
95 #include "mkbd.h"
96
97 #define PVRREG_FBSTART 0x05000000
98 #define PVRREG_REGSTART 0x005f8000
99
100 #define PVRREG_BRDCOLR 0x40
101 #define BRDCOLR_BLUE(x) ((x) << 0)
102 #define BRDCOLR_GREEN(x) ((x) << 8)
103 #define BRDCOLR_RED(x) ((x) << 16)
104
105 #define PVRREG_DIWMODE 0x44
106 #define DIWMODE_DE (1U << 0) /* display enable */
107 #define DIWMODE_SD (1U << 1) /* scan double enable */
108 #define DIWMODE_COL(x) ((x) << 2)
109 #define DIWMODE_COL_RGB555 DIWMODE_COL(0) /* RGB555, 16-bit */
110 #define DIWMODE_COL_RGB565 DIWMODE_COL(1) /* RGB565, 16-bit */
111 #define DIWMODE_COL_RGB888 DIWMODE_COL(2) /* RGB888, 24-bit */
112 #define DIWMODE_COL_ARGB888 DIWMODE_COL(3) /* RGB888, 32-bit */
113 #define DIWMODE_C (1U << 23) /* 2x clock enable (VGA) */
114
115 #define PVRREG_DIWADDRL 0x50
116
117 #define PVRREG_DIWADDRS 0x54
118
119 #define PVRREG_DIWSIZE 0x5c
120 #define DIWSIZE_DPL(x) ((x) << 0) /* pixel data per line */
121 #define DIWSIZE_LPF(x) ((x) << 10) /* lines per field */
122 #define DIWSIZE_MODULO(x) ((x) << 20) /* words to skip + 1 */
123
124 #define PVRREG_RASEVTPOS 0xcc
125 #define RASEVTPOS_BOTTOM(x) ((x) << 0)
126 #define RASEVTPOS_TOP(x) ((x) << 16)
127
128 #define PVRREG_SYNCCONF 0xd0
129 #define SYNCCONF_VP (1U << 0) /* V-sync polarity */
130 #define SYNCCONF_HP (1U << 1) /* H-sync polarity */
131 #define SYNCCONF_I (1U << 4) /* interlace */
132 #define SYNCCONF_BC(x) (1U << 6) /* broadcast standard */
133 #define SYNCCONF_VO (1U << 8) /* video output enable */
134
135 #define PVRREG_BRDHORZ 0xd4
136 #define BRDHORZ_STOP(x) ((x) << 0)
137 #define BRDHORZ_START(x) ((x) << 16)
138
139 #define PVRREG_SYNCSIZE 0xd8
140 #define SYNCSIZE_H(x) ((x) << 0)
141 #define SYNCSIZE_V(x) ((x) << 16)
142
143 #define PVRREG_BRDVERT 0xdc
144 #define BRDVERT_STOP(x) ((x) << 0)
145 #define BRDVERT_START(x) ((x) << 16)
146
147 #define PVRREG_DIWCONF 0xe8
148 #define DIWCONF_LR (1U << 8) /* low-res */
149 #define DIWCONF_MAGIC (22 << 16)
150
151 #define PVRREG_DIWHSTRT 0xec
152
153 #define PVRREG_DIWVSTRT 0xf0
154 #define DIWVSTRT_V1(x) ((x) << 0)
155 #define DIWVSTRT_V2(x) ((x) << 16)
156
157 #define PVR_REG_READ(dc, reg) \
158 ((__volatile uint32_t *)(dc)->dc_regvaddr)[(reg) >> 2]
159 #define PVR_REG_WRITE(dc, reg, val) \
160 ((__volatile uint32_t *)(dc)->dc_regvaddr)[(reg) >> 2] = (val)
161
162 struct fb_devconfig {
163 vaddr_t dc_vaddr; /* framebuffer virtual address */
164 vaddr_t dc_paddr; /* framebuffer physical address */
165 vaddr_t dc_regvaddr; /* registers virtual address */
166 vaddr_t dc_regpaddr; /* registers physical address */
167 int dc_wid; /* width of frame buffer */
168 int dc_ht; /* height of frame buffer */
169 int dc_depth; /* depth, bits per pixel */
170 int dc_rowbytes; /* bytes in a FB scan line */
171 vaddr_t dc_videobase; /* base of flat frame buffer */
172 int dc_blanked; /* currently has video disabled */
173 int dc_dispflags; /* display flags */
174 int dc_tvsystem; /* TV broadcast system */
175
176 struct rasops_info rinfo;
177 };
178
179 #define PVR_RGBMODE 0x01 /* RGB or composite */
180 #define PVR_VGAMODE 0x02 /* VGA */
181
182 struct pvr_softc {
183 struct device sc_dev;
184 struct fb_devconfig *sc_dc; /* device configuration */
185 int nscreens;
186 };
187
188 int pvr_match(struct device *, struct cfdata *, void *);
189 void pvr_attach(struct device *, struct device *, void *);
190
191 struct cfattach pvr_ca = {
192 sizeof(struct pvr_softc), pvr_match, pvr_attach,
193 };
194
195 void pvr_getdevconfig(struct fb_devconfig *);
196
197 struct fb_devconfig pvr_console_dc;
198
199 char pvr_stdscreen_textgeom[32] = { "std" }; /* XXX yuck */
200
201 struct wsscreen_descr pvr_stdscreen = {
202 pvr_stdscreen_textgeom, 0, 0,
203 0, /* textops */
204 0, 0,
205 WSSCREEN_WSCOLORS,
206 };
207
208 const struct wsscreen_descr *_pvr_scrlist[] = {
209 &pvr_stdscreen,
210 };
211
212 const struct wsscreen_list pvr_screenlist = {
213 sizeof(_pvr_scrlist) / sizeof(struct wsscreen_descr *), _pvr_scrlist
214 };
215
216 int pvrioctl(void *, u_long, caddr_t, int, struct proc *);
217 paddr_t pvrmmap(void *, off_t, int);
218
219 int pvr_alloc_screen(void *, const struct wsscreen_descr *,
220 void **, int *, int *, long *);
221 void pvr_free_screen(void *, void *);
222 int pvr_show_screen(void *, void *, int,
223 void (*)(void *, int, int), void *);
224
225 const struct wsdisplay_accessops pvr_accessops = {
226 pvrioctl,
227 pvrmmap,
228 pvr_alloc_screen,
229 pvr_free_screen,
230 pvr_show_screen,
231 NULL, /* load_font */
232 };
233
234 void pvrinit(struct fb_devconfig *);
235
236 int pvr_is_console;
237
238 int
239 pvr_match(struct device *parent, struct cfdata *match, void *aux)
240 {
241
242 if (strcmp("pvr", match->cf_driver->cd_name) != 0)
243 return (0);
244
245 return (1);
246 }
247
248 void
249 pvr_getdevconfig(struct fb_devconfig *dc)
250 {
251 int i, cookie;
252
253 dc->dc_paddr = PVRREG_FBSTART;
254 dc->dc_vaddr = SH3_PHYS_TO_P2SEG(dc->dc_paddr);
255
256 dc->dc_regpaddr = PVRREG_REGSTART;
257 dc->dc_regvaddr = SH3_PHYS_TO_P2SEG(dc->dc_regpaddr);
258
259 dc->dc_wid = 640;
260 dc->dc_ht = 480;
261 dc->dc_depth = 16;
262 dc->dc_rowbytes = dc->dc_wid * (dc->dc_depth / 8);
263 dc->dc_videobase = dc->dc_vaddr;
264 dc->dc_blanked = 0;
265 dc->dc_dispflags = 0;
266
267 /* Clear the screen. */
268 for (i = 0; i < dc->dc_ht * dc->dc_rowbytes; i += sizeof(u_int32_t))
269 *(u_int32_t *)(dc->dc_videobase + i) = 0x0;
270
271 /* Initialize the device. */
272 pvrinit(dc);
273
274 dc->rinfo.ri_flg = 0;
275 dc->rinfo.ri_depth = dc->dc_depth;
276 dc->rinfo.ri_bits = (void *) dc->dc_videobase;
277 dc->rinfo.ri_width = dc->dc_wid;
278 dc->rinfo.ri_height = dc->dc_ht;
279 dc->rinfo.ri_stride = dc->dc_rowbytes;
280
281 wsfont_init();
282 /* prefer 8 pixel wide font */
283 cookie = wsfont_find(NULL, 8, 0, 0, WSDISPLAY_FONTORDER_L2R,
284 WSDISPLAY_FONTORDER_L2R);
285 if (cookie <= 0)
286 cookie = wsfont_find(NULL, 0, 0, 0, WSDISPLAY_FONTORDER_L2R,
287 WSDISPLAY_FONTORDER_L2R);
288 if (cookie <= 0) {
289 printf("pvr: font table is empty\n");
290 return;
291 }
292
293 if (wsfont_lock(cookie, &dc->rinfo.ri_font)) {
294 printf("pvr: unable to lock font\n");
295 return;
296 }
297 dc->rinfo.ri_wsfcookie = cookie;
298
299 rasops_init(&dc->rinfo, 500, 500);
300
301 /* XXX shouldn't be global */
302 pvr_stdscreen.nrows = dc->rinfo.ri_rows;
303 pvr_stdscreen.ncols = dc->rinfo.ri_cols;
304 pvr_stdscreen.textops = &dc->rinfo.ri_ops;
305 pvr_stdscreen.capabilities = dc->rinfo.ri_caps;
306
307 /* XXX yuck */
308 sprintf(pvr_stdscreen_textgeom, "%dx%d", pvr_stdscreen.ncols,
309 pvr_stdscreen.nrows);
310 }
311
312 void
313 pvr_attach(struct device *parent, struct device *self, void *aux)
314 {
315 struct pvr_softc *sc = (void *) self;
316 struct wsemuldisplaydev_attach_args waa;
317 int console;
318 static const char *tvsystem_name[4] =
319 { "NTSC", "PAL", "PAL-M", "PAL-N" };
320
321 console = pvr_is_console;
322 if (console) {
323 sc->sc_dc = &pvr_console_dc;
324 sc->nscreens = 1;
325 } else {
326 sc->sc_dc = malloc(sizeof(struct fb_devconfig), M_DEVBUF,
327 M_WAITOK);
328 pvr_getdevconfig(sc->sc_dc);
329 }
330 printf(": %d x %d, %dbpp, %s, %s\n", sc->sc_dc->dc_wid,
331 sc->sc_dc->dc_ht, sc->sc_dc->dc_depth,
332 (sc->sc_dc->dc_dispflags & PVR_VGAMODE) ? "VGA" :
333 tvsystem_name[sc->sc_dc->dc_tvsystem],
334 (sc->sc_dc->dc_dispflags & PVR_RGBMODE) ? "RGB" : "composite");
335
336 /* XXX Colormap initialization? */
337
338 waa.console = console;
339 waa.scrdata = &pvr_screenlist;
340 waa.accessops = &pvr_accessops;
341 waa.accesscookie = sc;
342
343 (void) config_found(self, &waa, wsemuldisplaydevprint);
344 }
345
346 int
347 pvrioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
348 {
349 struct pvr_softc *sc = v;
350 struct fb_devconfig *dc = sc->sc_dc;
351
352 switch (cmd) {
353 case WSDISPLAYIO_GTYPE:
354 *(u_int *)data = WSDISPLAY_TYPE_DCPVR;
355 return (0);
356
357 case WSDISPLAYIO_GINFO:
358 #define wsd_fbip ((struct wsdisplay_fbinfo *)data)
359 wsd_fbip->height = sc->sc_dc->dc_ht;
360 wsd_fbip->width = sc->sc_dc->dc_wid;
361 wsd_fbip->depth = sc->sc_dc->dc_depth;
362 wsd_fbip->cmsize = 0; /* XXX Colormap */
363 #undef wsd_fbip
364 return (0);
365
366 case WSDISPLAYIO_GETCMAP:
367 case WSDISPLAYIO_PUTCMAP:
368 return (EPASSTHROUGH); /* XXX Colormap */
369
370 case WSDISPLAYIO_SVIDEO:
371 return (EPASSTHROUGH); /* XXX */
372
373 case WSDISPLAYIO_GVIDEO:
374 *(u_int *)data = dc->dc_blanked ?
375 WSDISPLAYIO_VIDEO_OFF : WSDISPLAYIO_VIDEO_ON;
376 return (0);
377
378 case WSDISPLAYIO_GCURPOS:
379 case WSDISPLAYIO_SCURPOS:
380 case WSDISPLAYIO_GCURMAX:
381 case WSDISPLAYIO_GCURSOR:
382 case WSDISPLAYIO_SCURSOR:
383 return (EPASSTHROUGH); /* XXX */
384 }
385
386 return (EPASSTHROUGH);
387 }
388
389 paddr_t
390 pvrmmap(void *v, off_t offset, int prot)
391 {
392
393 /*
394 * XXX This should be easy to support -- just need to define
395 * XXX offsets for the contol regs, etc.
396 */
397
398 struct pvr_softc *sc = v;
399 struct fb_devconfig *dc = sc->sc_dc;
400 paddr_t addr;
401
402 if (offset >= 0 &&
403 offset < sh3_round_page(dc->dc_rowbytes * dc->dc_ht))
404 addr = sh3_btop(dc->dc_paddr + offset);
405 else
406 addr = (-1); /* XXX bogus */
407
408 return addr;
409 }
410
411 int
412 pvr_alloc_screen(void *v, const struct wsscreen_descr *type,
413 void **cookiep, int *curxp, int *curyp, long *attrp)
414 {
415 struct pvr_softc *sc = v;
416 long defattr;
417
418 if (sc->nscreens > 0)
419 return (ENOMEM);
420
421 *cookiep = &sc->sc_dc->rinfo; /* one and only for now */
422 *curxp = 0;
423 *curyp = 0;
424 (*sc->sc_dc->rinfo.ri_ops.alloc_attr)(&sc->sc_dc->rinfo, 0, 0, 0,
425 &defattr);
426 *attrp = defattr;
427 sc->nscreens++;
428 return (0);
429 }
430
431 void
432 pvr_free_screen(void *v, void *cookie)
433 {
434 struct pvr_softc *sc = v;
435
436 if (sc->sc_dc == &pvr_console_dc)
437 panic("pvr_free_screen: console");
438
439 sc->nscreens--;
440 }
441
442 int
443 pvr_show_screen(void *v, void *cookie, int waitok,
444 void (*cb)(void *, int, int), void *cbarg)
445 {
446
447 return (0);
448 }
449
450 static void
451 pvr_check_cable(struct fb_devconfig *dc)
452 {
453 __volatile u_int32_t *porta =
454 (__volatile u_int32_t *)0xff80002c;
455 u_int16_t v;
456
457 /* PORT8 and PORT9 is input */
458 *porta = (*porta & ~0xf0000) | 0xa0000;
459
460 /* Read PORT8 and PORT9 */
461 v = ((*(__volatile u_int16_t *)(porta + 1)) >> 8) & 3;
462
463 if ((v & 2) == 0)
464 dc->dc_dispflags |= PVR_VGAMODE|PVR_RGBMODE;
465 else if ((v & 1) == 0)
466 dc->dc_dispflags |= PVR_RGBMODE;
467 }
468
469 static void
470 pvr_check_tvsys(struct fb_devconfig *dc)
471 {
472
473 /* XXX should use flashmem device when one exists */
474 dc->dc_tvsystem = (*(__volatile u_int8_t *)0xa021a004) & 3;
475 }
476
477 void
478 pvrinit(struct fb_devconfig *dc)
479 {
480 int display_lines_per_field;
481 int v_absolute_size;
482 int h_absolute_size;
483 int vborder_start, vborder_stop;
484 int hborder_start, hborder_stop;
485 int modulo = 1, voffset, hoffset;
486
487 pvr_check_cable(dc);
488 pvr_check_tvsys(dc);
489
490 PVR_REG_WRITE(dc, 8, 0); /* reset */
491 PVR_REG_WRITE(dc, PVRREG_BRDCOLR, 0); /* black border */
492
493 if (dc->dc_dispflags & PVR_VGAMODE) {
494 v_absolute_size = 524;
495 h_absolute_size = 857;
496
497 display_lines_per_field = 480;
498 hoffset = 164;
499 voffset = 36;
500
501 hborder_start = 126;
502 hborder_stop = 837;
503
504 vborder_start = 40;
505 vborder_stop = 444; /* XXX */
506
507 /* 31kHz, RGB565 */
508 PVR_REG_WRITE(dc, PVRREG_DIWMODE,
509 DIWMODE_C | DIWMODE_COL_RGB565);
510
511 /* video output */
512 PVR_REG_WRITE(dc, PVRREG_SYNCCONF, SYNCCONF_VO);
513 } else {
514 if (dc->dc_tvsystem & 1) {
515 /* 50 Hz PAL */
516 v_absolute_size = 624;
517 h_absolute_size = 863;
518
519 display_lines_per_field = 240;
520 hoffset = 174;
521 voffset = 18;
522
523 hborder_start = 116;
524 hborder_stop = 843;
525
526 vborder_start = 44;
527 vborder_stop = 536; /* XXX */
528 } else {
529 /* 60 Hz NTSC */
530 v_absolute_size = 524;
531 h_absolute_size = 857;
532
533 display_lines_per_field = 240;
534 hoffset = 170;
535 voffset = 28;
536
537 hborder_start = 126;
538 hborder_stop = 837;
539
540 vborder_start = 18;
541 vborder_stop = 506; /* XXX */
542 }
543
544 modulo += 640 * 2 / 4; /* interlace -> skip every other line */
545
546 /* 15kHz, RGB565 */
547 PVR_REG_WRITE(dc, PVRREG_DIWMODE,
548 DIWMODE_COL_RGB565);
549
550 /* video output, PAL/NTSC, interlace */
551 PVR_REG_WRITE(dc, PVRREG_SYNCCONF,
552 SYNCCONF_VO | SYNCCONF_I | SYNCCONF_BC(dc->dc_tvsystem));
553 }
554
555 /* video base address, long field */
556 PVR_REG_WRITE(dc, PVRREG_DIWADDRL, 0);
557
558 /* video base address, short field */
559 PVR_REG_WRITE(dc, PVRREG_DIWADDRS, 640 * 2);
560
561 /* video size */
562 PVR_REG_WRITE(dc, PVRREG_DIWSIZE, DIWSIZE_MODULO(modulo) |
563 DIWSIZE_LPF(display_lines_per_field - 1) |
564 DIWSIZE_DPL(640 * 2 / 4 - 1));
565
566 PVR_REG_WRITE(dc, PVRREG_DIWVSTRT, /* V start */
567 DIWVSTRT_V1(voffset) | DIWVSTRT_V2(voffset));
568 PVR_REG_WRITE(dc, PVRREG_BRDVERT, /* V border */
569 BRDVERT_START(vborder_start) | BRDVERT_STOP(vborder_stop));
570 PVR_REG_WRITE(dc, PVRREG_DIWHSTRT, hoffset); /* H start */
571 PVR_REG_WRITE(dc, PVRREG_SYNCSIZE, /* HV counter */
572 SYNCSIZE_V(v_absolute_size) | SYNCSIZE_H(h_absolute_size));
573 PVR_REG_WRITE(dc, PVRREG_BRDHORZ, /* H border */
574 BRDHORZ_START(hborder_start) | BRDHORZ_STOP(hborder_stop));
575 PVR_REG_WRITE(dc, PVRREG_DIWCONF, DIWCONF_MAGIC);
576
577 /* RGB / composite */
578 *(__volatile u_int32_t *)
579 SH3_PHYS_TO_P2SEG(0x00702c00) =
580 ((dc->dc_dispflags & PVR_RGBMODE) ? 0 : 3) << 8;
581
582 /* display on */
583 PVR_REG_WRITE(dc, PVRREG_DIWMODE,
584 PVR_REG_READ(dc, PVRREG_DIWMODE) | DIWMODE_DE);
585 }
586
587 /* Console support. */
588
589 void pvrcnprobe(struct consdev *);
590 void pvrcninit(struct consdev *);
591
592 void
593 pvrcninit(struct consdev *cndev)
594 {
595 struct fb_devconfig *dcp = &pvr_console_dc;
596 long defattr;
597
598 pvr_getdevconfig(dcp);
599 (*dcp->rinfo.ri_ops.alloc_attr)(&dcp->rinfo, 0, 0, 0, &defattr);
600 wsdisplay_cnattach(&pvr_stdscreen, &dcp->rinfo, 0, 0, defattr);
601
602 pvr_is_console = 1;
603
604 cn_tab->cn_pri = CN_INTERNAL;
605
606 #if NMKBD > 0
607 mkbd_cnattach(); /* connect keyboard and screen together */
608 #endif
609 }
610
611 void
612 pvrcnprobe(struct consdev *cndev)
613 {
614 #if NWSDISPLAY > 0
615 int maj, unit;
616 #endif
617 cndev->cn_dev = NODEV;
618 cndev->cn_pri = CN_NORMAL;
619
620 #if NWSDISPLAY > 0
621 unit = 0;
622 for (maj = 0; maj < nchrdev; maj++) {
623 if (cdevsw[maj].d_open == wsdisplayopen)
624 break;
625 }
626 if (maj != nchrdev) {
627 cndev->cn_pri = CN_INTERNAL;
628 cndev->cn_dev = makedev(maj, unit);
629 }
630 #endif
631 }
632