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