Annotation of sys/arch/jornada/dev/jfb.c, Revision 1.2
1.2 ! nbrk 1: /* $Id: jfb.c,v 1.1.1.1 2008/03/04 16:09:01 nbrk Exp $ */
1.1 nbrk 2: /*
3: * Jornada framebuffer.
4: * 640x240 @16bpp
5: */
6: #include <sys/param.h>
7: #include <sys/systm.h>
8: #include <sys/device.h>
9: #include <sys/proc.h>
10: #include <sys/conf.h>
11:
12: #include <dev/wscons/wsdisplayvar.h>
13: #include <dev/rasops/rasops.h>
14: #include <dev/wscons/wsconsio.h>
15: #include <dev/wsfont/vt220l8x10.h>
16:
17: #include <machine/bus.h>
18:
19: #include <arm/sa11x0/sa11x0_reg.h>
20: #include <arm/sa11x0/sa11x0_var.h>
21: #include <jornada/dev/jfbreg.h>
22:
23: #include "wsdisplay.h"
24:
25: #define JFB_DFLTWIDTH 640
26: #define JFB_DFLTHEIGHT 240
27: #define JFB_DFLTBPP 16
28:
29: struct jfb_softc {
30: struct device sc_dev;
31: bus_space_tag_t sc_bust;
32: bus_space_handle_t sc_bush;
33: uint8_t *sc_bits;
34:
35: int sc_width;
36: int sc_height;
37: int sc_depth;
38: int sc_linebytes;
39:
40: int sc_rows;
41: int sc_cols;
42:
43: struct rasops_info sc_ri;
1.2 ! nbrk 44: long sc_defattr; /* XXX kill me */
1.1 nbrk 45:
46: struct wsscreen_descr sc_wsd;
47: struct wsscreen_list sc_wsl;
48: struct wsscreen_descr *sc_scrlist[1];
49: };
50:
51: int jfb_match(struct device *parent, void *cf, void *aux);
52: void jfb_attach(struct device *parent, struct device *self, void *aux);
53: void jfbfakecnattach(bus_addr_t addr);
54: void jfb_rasopsinit(struct jfb_softc *sc);
55: void jfb_setcmap(struct rasops_info *ri);
56:
57: struct jfb_softc jfb_sc;
58: int jfb_initted = 0;
59:
60: /* autoconf stuff */
61: struct cfattach jfb_ca = {
62: sizeof(struct jfb_softc), jfb_match, jfb_attach, NULL, NULL
63: };
64:
65: struct cfdriver jfb_cd = {
66: NULL, "jfb", DV_DULL
67: };
68:
69:
70: int
71: jfb_match(struct device *parent, void *cf, void *aux)
72: {
73: return(1);
74: }
75:
76: void
77: jfb_attach(struct device *parent, struct device *self, void *aux)
78: {
79: struct jfb_softc *sc = (void *)self;
80: struct saip_attach_args *saa = aux;
81: struct wsemuldisplaydev_attach_args waa;
82:
83: sc->sc_bust = saa->sai_iot;
84:
85: /* use bootstrap softc if it is already configured */
86: // if (jfb_initted)
87: // *sc = jfb_sc;
88:
89: if (bus_space_map(sc->sc_bust, saa->sai_addr, JFB_SIZE , BUS_SPACE_MAP_LINEAR, &sc->sc_bush)) {
90: printf(": can't map i/o space\n");
91: return;
92: }
93:
94: sc->sc_bits = (uint8_t *)sc->sc_bush;
95:
96: /* TODO use flags for mode selection */
97: sc->sc_width = JFB_DFLTWIDTH;
98: sc->sc_height = JFB_DFLTHEIGHT;
99: sc->sc_depth = JFB_DFLTBPP;
100: sc->sc_linebytes = sc->sc_width * (sc->sc_depth / 8);
101:
102: sc->sc_cols = 80;
103: sc->sc_rows = 24;
104:
105: jfb_rasopsinit(sc);
106:
107: printf(": Jornada framebuffer (%dx%d @%dbpp)\n", sc->sc_width, sc->sc_height, sc->sc_depth);
108:
109: sc->sc_scrlist[0] = &sc->sc_wsd;
110: sc->sc_wsl.nscreens = 1;
111: sc->sc_wsl.screens = (const struct wsscreen_descr **)sc->sc_scrlist;
112:
113: waa.scrdata = &sc->sc_wsl;
114: waa.accesscookie = sc;
115: waa.defaultscreens = 0;
116:
1.2 ! nbrk 117: // config_found((struct device *)sc, &waa, wsemuldisplaydevprint);
1.1 nbrk 118:
119: return;
120: }
121:
122: void
123: jfbfakecnattach(bus_addr_t addr)
124: {
125: struct jfb_softc *sc = &jfb_sc;
126:
127: sc->sc_bits = (uint8_t *)addr;
128:
129: if (jfb_initted == 0) {
130: /*
131: * First attachment.
132: * Initialize with defaults.
133: */
134:
135: /* clear the screen */
136: sc->sc_ri.ri_flg = RI_CLEAR | RI_FULLCLEAR;
137:
138: sc->sc_width = JFB_DFLTWIDTH;
139: sc->sc_height = JFB_DFLTHEIGHT;
140: sc->sc_depth = JFB_DFLTBPP;
141: sc->sc_linebytes = sc->sc_width * (sc->sc_depth / 8);
142:
143: sc->sc_cols = 80;
144: sc->sc_rows = 24;
145:
146: /* set up rasops */
147: jfb_rasopsinit(sc);
148:
149: jfb_initted = 1;
150:
151: wsdisplay_cnattach(&sc->sc_wsd, &sc->sc_ri, 0, 0, 0);
152: } else {
153: /*
154: * Already attached.
155: * Tweak some settings and reconfigure rasops.
156: */
157:
158: /* reset ri_bits */
159: sc->sc_ri.ri_flg &= ~RI_CFGDONE;
160: sc->sc_ri.ri_bits = sc->sc_bits;
161: /* do not clear the screen */
162: sc->sc_ri.ri_flg &= ~RI_CLEAR;
163:
164: rasops_reconfig(&sc->sc_ri, 160, 160);
165: }
166: }
167:
168: void
169: jfb_rasopsinit(struct jfb_softc *sc)
170: {
171: struct rasops_info *ri = &sc->sc_ri;
172: struct wsscreen_descr *wsd = &sc->sc_wsd;
173: extern struct wsdisplay_font vt220l8x10;
174:
175: ri->ri_hw = sc;
176: ri->ri_bits = sc->sc_bits;
177:
178: /* claim minimal colour capabilities */
179: ri->ri_caps = WSSCREEN_WSCOLORS;
180:
181: ri->ri_depth = sc->sc_depth;
182: ri->ri_width = sc->sc_width;
183: ri->ri_height = sc->sc_height;
184: ri->ri_stride = sc->sc_linebytes;
185:
186: /* FIXME: see how colors are packed in 16bits/pixel ? */
187: ri->ri_rnum = 5;
188: ri->ri_gnum = 6;
189: ri->ri_bnum = 5;
190: ri->ri_rpos = 11;
191: ri->ri_gpos = 5;
192: ri->ri_bpos = 0;
193:
194: ri->ri_font = &vt220l8x10;
195:
196: /* XXX XXX please tell me why? */
197: /* rasops_init(ri, sc->sc_cols, sc->sc_rows); */
198: rasops_init(ri, 160, 160);
199:
200: /* tune colours */
201: jfb_setcmap(ri);
202:
1.2 ! nbrk 203: /* XXX XXX XXX */
! 204: ri->ri_ops.alloc_attr(ri,
! 205: WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, &sc->sc_defattr);
! 206: /* initialize wsscreen_descr */
1.1 nbrk 207: strlcpy(wsd->name, "std", sizeof(wsd->name));
208: wsd->ncols = sc->sc_cols;
209: wsd->nrows = sc->sc_rows;
210: wsd->capabilities = ri->ri_caps;
211: wsd->textops = &ri->ri_ops;
212: }
213:
214: void
215: jfb_setcmap(struct rasops_info *ri)
216: {
217: /* more intensive white */
218: ri->ri_devcmap[WSCOL_WHITE] = 0xffff;
219: }
CVSweb