summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64/dev
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-11-29 22:07:42 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-11-29 22:07:42 +0000
commitcefdf5e62eae54a4c575c27947ca681a438ade33 (patch)
treef6057fe704b1e777395bda6ae431013303d9ffe7 /sys/arch/sparc64/dev
parent0ade68e7821ecaff132d0ec95dd118093bff8605 (diff)
Move the struct wsscreen_descr from a per-driver global to a per-instance
field of the sunfb structure. This allows multiple instances of the same driver, but with different resolutions (such as a couple of vigra or a TGX cgsix and a TGX+ cgsix) to use distinct wsscreen_descr structures featuring different resolution information. Doing this allows more wsscreen_descr fiddling inside the sparc* fb api, and results in some code shrinkage (about 4KB on sparc GENERIC).
Diffstat (limited to 'sys/arch/sparc64/dev')
-rw-r--r--sys/arch/sparc64/dev/creator.c30
-rw-r--r--sys/arch/sparc64/dev/fb.c60
2 files changed, 51 insertions, 39 deletions
diff --git a/sys/arch/sparc64/dev/creator.c b/sys/arch/sparc64/dev/creator.c
index be9a0203042..923aebccffe 100644
--- a/sys/arch/sparc64/dev/creator.c
+++ b/sys/arch/sparc64/dev/creator.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: creator.c,v 1.29 2003/06/24 19:41:33 miod Exp $ */
+/* $OpenBSD: creator.c,v 1.30 2004/11/29 22:07:40 miod Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -47,20 +47,6 @@
#include <sparc64/dev/creatorreg.h>
#include <sparc64/dev/creatorvar.h>
-struct wsscreen_descr creator_stdscreen = {
- "std",
-};
-
-const struct wsscreen_descr *creator_scrlist[] = {
- &creator_stdscreen,
- /* XXX other formats? */
-};
-
-struct wsscreen_list creator_screenlist = {
- sizeof(creator_scrlist) / sizeof(struct wsscreen_descr *),
- creator_scrlist
-};
-
int creator_ioctl(void *, u_long, caddr_t, int, struct proc *);
int creator_alloc_screen(void *, const struct wsscreen_descr *, void **,
int *, int *, long *);
@@ -100,7 +86,6 @@ struct cfdriver creator_cd = {
void
creator_attach(struct creator_softc *sc)
{
- struct wsemuldisplaydev_attach_args waa;
char *model;
int btype;
@@ -151,22 +136,13 @@ creator_attach(struct creator_softc *sc)
creator_ras_init(sc);
}
- creator_stdscreen.capabilities = sc->sc_sunfb.sf_ro.ri_caps;
- creator_stdscreen.nrows = sc->sc_sunfb.sf_ro.ri_rows;
- creator_stdscreen.ncols = sc->sc_sunfb.sf_ro.ri_cols;
- creator_stdscreen.textops = &sc->sc_sunfb.sf_ro.ri_ops;
-
if (sc->sc_console) {
sc->sc_sunfb.sf_ro.ri_updatecursor = creator_ras_updatecursor;
- fbwscons_console_init(&sc->sc_sunfb, &creator_stdscreen, -1,
+ fbwscons_console_init(&sc->sc_sunfb, -1,
NULL);
}
- waa.console = sc->sc_console;
- waa.scrdata = &creator_screenlist;
- waa.accessops = &creator_accessops;
- waa.accesscookie = sc;
- config_found(&sc->sc_sunfb.sf_dev, &waa, wsemuldisplaydevprint);
+ fbwscons_attach(&sc->sc_sunfb, &creator_accessops, sc->sc_console);
}
int
diff --git a/sys/arch/sparc64/dev/fb.c b/sys/arch/sparc64/dev/fb.c
index 22a1f5ea8c4..fd257bf332c 100644
--- a/sys/arch/sparc64/dev/fb.c
+++ b/sys/arch/sparc64/dev/fb.c
@@ -1,8 +1,8 @@
-/* $OpenBSD: fb.c,v 1.5 2004/02/29 21:24:37 miod Exp $ */
+/* $OpenBSD: fb.c,v 1.6 2004/11/29 22:07:40 miod Exp $ */
/* $NetBSD: fb.c,v 1.23 1997/07/07 23:30:22 pk Exp $ */
/*
- * Copyright (c) 2002 Miodrag Vallat
+ * Copyright (c) 2002, 2004 Miodrag Vallat.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -86,6 +86,9 @@
#include "wsdisplay.h"
+static int a2int(char *, int);
+static void fb_initwsd(struct sunfb *);
+
/*
* emergency unblank code
* XXX should be somewhat moved to wscons MI code
@@ -129,9 +132,7 @@ fb_setsize(struct sunfb *sf, int def_depth, int def_width, int def_height,
sf->sf_fbsize = sf->sf_height * sf->sf_linebytes;
}
-int a2int(char *, int);
-
-int
+static int
a2int(char *cp, int deflt)
{
int i = 0;
@@ -143,6 +144,17 @@ a2int(char *cp, int deflt)
return (i);
}
+/* setup the embedded wsscreen_descr structure from rasops settings */
+static void
+fb_initwsd(struct sunfb *sf)
+{
+ strlcpy(sf->sf_wsd.name, "std", sizeof(sf->sf_wsd.name));
+ sf->sf_wsd.capabilities = sf->sf_ro.ri_caps;
+ sf->sf_wsd.nrows = sf->sf_ro.ri_rows;
+ sf->sf_wsd.ncols = sf->sf_ro.ri_cols;
+ sf->sf_wsd.textops = &sf->sf_ro.ri_ops;
+}
+
void
fbwscons_init(struct sunfb *sf, int flags)
{
@@ -162,7 +174,7 @@ fbwscons_init(struct sunfb *sf, int flags)
}
void
-fbwscons_console_init(struct sunfb *sf, struct wsscreen_descr *wsc, int row,
+fbwscons_console_init(struct sunfb *sf, int row,
void (*burner)(void *, u_int, u_int))
{
long defattr;
@@ -194,10 +206,10 @@ fbwscons_console_init(struct sunfb *sf, struct wsscreen_descr *wsc, int row,
* Scale back rows and columns if the font would not otherwise
* fit on this display. Without this we would panic later.
*/
- if (sf->sf_ro.ri_crow >= wsc->nrows)
- sf->sf_ro.ri_crow = wsc->nrows - 1;
- if (sf->sf_ro.ri_ccol >= wsc->ncols)
- sf->sf_ro.ri_ccol = wsc->ncols - 1;
+ if (sf->sf_ro.ri_crow >= sf->sf_ro.ri_rows)
+ sf->sf_ro.ri_crow = sf->sf_ro.ri_rows - 1;
+ if (sf->sf_ro.ri_ccol >= sf->sf_ro.ri_cols)
+ sf->sf_ro.ri_ccol = sf->sf_ro.ri_cols - 1;
/*
* Select appropriate color settings to mimic a
@@ -210,7 +222,7 @@ fbwscons_console_init(struct sunfb *sf, struct wsscreen_descr *wsc, int row,
wskernel_fg = 255;
}
- if (ISSET(wsc->capabilities, WSSCREEN_WSCOLORS) &&
+ if (ISSET(sf->sf_ro.ri_caps, WSSCREEN_WSCOLORS) &&
sf->sf_depth == 8) {
sf->sf_ro.ri_ops.alloc_attr(&sf->sf_ro,
WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, &defattr);
@@ -218,7 +230,8 @@ fbwscons_console_init(struct sunfb *sf, struct wsscreen_descr *wsc, int row,
sf->sf_ro.ri_ops.alloc_attr(&sf->sf_ro, 0, 0, 0, &defattr);
}
- wsdisplay_cnattach(wsc, &sf->sf_ro,
+ fb_initwsd(sf);
+ wsdisplay_cnattach(&sf->sf_wsd, &sf->sf_ro,
sf->sf_ro.ri_ccol, sf->sf_ro.ri_crow, defattr);
/* remember screen burner routine */
@@ -250,4 +263,27 @@ fbwscons_setcolormap(struct sunfb *sf,
}
}
+void
+fbwscons_attach(struct sunfb *sf, struct wsdisplay_accessops *op, int isconsole)
+{
+ struct wsemuldisplaydev_attach_args waa;
+ struct wsscreen_descr *scrlist[1];
+ struct wsscreen_list screenlist;
+
+ if (isconsole == 0) {
+ /* done in wsdisplay_cnattach() earlier if console */
+ fb_initwsd(sf);
+ }
+
+ scrlist[0] = &sf->sf_wsd;
+ screenlist.nscreens = 1;
+ screenlist.screens = (const struct wsscreen_descr **)scrlist;
+
+ waa.console = isconsole;
+ waa.scrdata = &screenlist;
+ waa.accessops = op;
+ waa.accesscookie = sf;
+ config_found(&sf->sf_dev, &waa, wsemuldisplaydevprint);
+}
+
#endif /* NWSDISPLAY */