1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/* $OpenBSD: gfb.c,v 1.2 2013/10/20 20:07:27 miod Exp $ */
/*
* Copyright (c) 2009 Mark Kettenis.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/rasops/rasops.h>
#include <machine/fbvar.h>
struct gfb_softc {
struct sunfb sc_sunfb;
bus_space_tag_t sc_bt;
bus_space_handle_t sc_pixel_h;
int sc_console;
int sc_node;
u_int sc_mode;
};
int gfb_match(struct device *, void *, void *);
void gfb_attach(struct device *, struct device *, void *);
int gfb_ioctl(void *, u_long, caddr_t, int, struct proc *);
struct wsdisplay_accessops gfb_accessops = {
.ioctl = gfb_ioctl
};
struct cfdriver gfb_cd = {
NULL, "gfb", DV_DULL
};
struct cfattach gfb_ca = {
sizeof(struct gfb_softc), gfb_match, gfb_attach
};
int
gfb_match(struct device *parent, void *match, void *aux)
{
struct mainbus_attach_args *ma = aux;
if (strcmp(ma->ma_name, "SUNW,gfb") == 0)
return (1);
return (0);
}
void
gfb_attach(struct device *parent, struct device *self, void *aux)
{
struct gfb_softc *sc = (struct gfb_softc *)self;
struct mainbus_attach_args *ma = aux;
extern int fbnode;
sc->sc_bt = ma->ma_bustag;
printf("\n");
if (bus_space_map(ma->ma_bustag, ma->ma_reg[6].ur_paddr,
ma->ma_reg[6].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_pixel_h))
return;
sc->sc_console = (fbnode == ma->ma_node);
sc->sc_node = ma->ma_node;
fb_setsize(&sc->sc_sunfb, 32, 1152, 900, sc->sc_node, 0);
/* linesize has a fixed value, compensate */
sc->sc_sunfb.sf_linebytes = 16384;
sc->sc_sunfb.sf_fbsize = sc->sc_sunfb.sf_height * 16384;
sc->sc_sunfb.sf_ro.ri_bits = (void *)bus_space_vaddr(sc->sc_bt,
sc->sc_pixel_h);
sc->sc_sunfb.sf_ro.ri_hw = sc;
fbwscons_init(&sc->sc_sunfb, 0, sc->sc_console);
if (sc->sc_console)
fbwscons_console_init(&sc->sc_sunfb, -1);
fbwscons_attach(&sc->sc_sunfb, &gfb_accessops, sc->sc_console);
return;
}
int
gfb_ioctl(void *v, u_long cmd, caddr_t data, int flags, struct proc *p)
{
struct gfb_softc *sc = v;
struct wsdisplay_fbinfo *wdf;
switch (cmd) {
case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_UNKNOWN;
break;
case WSDISPLAYIO_SMODE:
sc->sc_mode = *(u_int *)data;
break;
case WSDISPLAYIO_GINFO:
wdf = (void *)data;
wdf->height = sc->sc_sunfb.sf_height;
wdf->width = sc->sc_sunfb.sf_width;
wdf->depth = sc->sc_sunfb.sf_depth;
wdf->cmsize = 256;
break;
case WSDISPLAYIO_LINEBYTES:
*(u_int *)data = sc->sc_sunfb.sf_linebytes;
break;
#if 0
case WSDISPLAYIO_GETCMAP:
return gfb_getcmap(sc, (struct wsdisplay_cmap *)data);
case WSDISPLAYIO_PUTCMAP:
return gfb_putcmap(sc, (struct wsdisplay_cmap *)data);
#endif
case WSDISPLAYIO_SVIDEO:
case WSDISPLAYIO_GVIDEO:
break;
case WSDISPLAYIO_GCURPOS:
case WSDISPLAYIO_SCURPOS:
case WSDISPLAYIO_GCURMAX:
case WSDISPLAYIO_GCURSOR:
case WSDISPLAYIO_SCURSOR:
default:
return -1; /* not supported yet */
}
return (0);
}
|