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