Beispiel #1
0
/*
 * Early console support.  Only used on hp300.
 */
int
sti_cnattach(struct sti_rom *rom, struct sti_screen *scr, bus_space_tag_t memt,
    bus_addr_t *bases, u_int codebase)
{
	bus_space_handle_t romh;
	u_int romend;
	int error;
	long defattr;

	if ((error = bus_space_map(memt, bases[0], PAGE_SIZE, 0, &romh)) != 0)
		return error;

	/*
	 * Compute real PROM size
	 */
	romend = sti_rom_size(memt, romh);

	bus_space_unmap(memt, romh, PAGE_SIZE);

	if ((error = bus_space_map(memt, bases[0], romend, 0, &romh)) != 0)
		return error;

	bases[0] = romh;
	if (sti_rom_setup(rom, memt, memt, romh, bases, codebase) != 0)
		return -1;
	scr->scr_rom = rom;
	if (sti_screen_setup(scr, STI_CLEARSCR) != 0)
		return -1;

	sti_alloc_attr(scr, 0, 0, 0, &defattr);
	wsdisplay_cnattach(&scr->scr_wsd, scr, 0, 0, defattr);

	return 0;
}
int
nextdisplay_cnattach(void)
{
	struct nextdisplay_config *dc = &nextdisplay_console_dc;
	long defattr;
	int iscolor;

	if (rom_machine_type == NeXT_WARP9C ||
	    rom_machine_type == NeXT_TURBO_COLOR)
		iscolor = 1;
	else
		iscolor = 0;

	/* set up the display */
	nextdisplay_init(&nextdisplay_console_dc, iscolor);
	nextdisplay_consaddr = nextdisplay_console_dc.dc_vaddr;

	rcons_allocattr(&dc->dc_rcons, 0, 0, 
			iscolor ? 0 : WSATTR_REVERSE, &defattr);

	wsdisplay_cnattach(iscolor ? &nextdisplay_color : &nextdisplay_mono,
			   &dc->dc_rcons, 0, 0, defattr);

	dc->isconsole = 1;
	return (0);
}
Beispiel #3
0
void
sti_end_attach(struct sti_softc *sc)
{
	struct sti_screen *scr = sc->sc_scr;

	if (scr == NULL)
		return;
#if NWSDISPLAY > 0
	else {
		struct wsemuldisplaydev_attach_args waa;
		scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;

		waa.console = sc->sc_flags & STI_CONSOLE ? 1 : 0;
		waa.scrdata = &scr->scr_screenlist;
		waa.accessops = &sti_accessops;
		waa.accesscookie = scr;

		/* attach as console if required */
		if (waa.console && !ISSET(sc->sc_flags, STI_ATTACHED)) {
			long defattr;

			sti_alloc_attr(scr, 0, 0, 0, &defattr);
			wsdisplay_cnattach(&scr->scr_wsd, scr,
			    0, scr->scr_wsd.nrows - 1, defattr);
			sc->sc_flags |= STI_ATTACHED;
		}

		config_found(sc->sc_dev, &waa, wsemuldisplaydevprint);
	}
#endif
}
Beispiel #4
0
void
sti_end_attach_screen(struct sti_softc *sc, struct sti_screen *scr, int console)
{
	struct wsemuldisplaydev_attach_args waa;

	scr->scr_wsmode = WSDISPLAYIO_MODE_EMUL;

	waa.console = console;
	waa.scrdata = &scr->scr_screenlist;
	waa.accessops = &sti_accessops;
	waa.accesscookie = scr;
	waa.defaultscreens = 0;

	/* attach as console if required */
	if (console && !ISSET(sc->sc_flags, STI_ATTACHED)) {
		long defattr;

		sti_alloc_attr(scr, 0, 0, 0, &defattr);
		wsdisplay_cnattach(&scr->scr_wsd, scr,
		    0, scr->scr_wsd.nrows - 1, defattr);
		sc->sc_flags |= STI_ATTACHED;
	}

	config_found(&sc->sc_dev, &waa, wsemuldisplaydevprint);
}
/*
 * Attach.. plug pointer in and print some info.
 * Then try and attach a wsdisplay or ite to us.
 * Note: self is NULL durring console init.
 */
void
grfattach(device_t parent, device_t self, void *aux)
{
#if NWSDISPLAY > 0
	struct wsemuldisplaydev_attach_args wa;
	long defattr;
#endif
	struct grf_softc *gp;
	int maj;

	gp = device_private(parent);
	gp->g_device = self;
	grfsp[gp->g_unit] = gp;

	/*
	 * find our major device number
	 */
	maj = cdevsw_lookup_major(&grf_cdevsw);

	gp->g_grfdev = makedev(maj, gp->g_unit);
	if (self != NULL) {
		printf(": width %d height %d", gp->g_display.gd_dwidth,
		    gp->g_display.gd_dheight);
		if (gp->g_display.gd_colors == 2)
			printf(" monochrome\n");
		else
			printf(" colors %d\n", gp->g_display.gd_colors);
#if NWSDISPLAY > 0
		vcons_init(&gp->g_vd, gp, gp->g_screens[0], gp->g_accessops);
		gp->g_vd.init_screen = grf_init_screen;
		if (gp->g_flags & GF_CONSOLE) {
			console_vcons.scr_flags |= VCONS_SCREEN_IS_STATIC;
			vcons_init_screen(&gp->g_vd,
			    &console_vcons, 1, &defattr);
			gp->g_screens[0]->textops =
			    &console_vcons.scr_ri.ri_ops;
			wsdisplay_cnattach(gp->g_screens[0],
			    &console_vcons.scr_ri, 0, 0, defattr);
			vcons_replay_msgbuf(&console_vcons);
		}

		/* attach wsdisplay */
		wa.console = (gp->g_flags & GF_CONSOLE) != 0;
		wa.scrdata = &gp->g_screenlist;
		wa.accessops = gp->g_accessops;
		wa.accesscookie = &gp->g_vd;
		config_found(self, &wa, wsemuldisplaydevprint);
#endif  /* NWSDISPLAY > 0 */
	}

#if NWSDISPLAY == 0
	/*
	 * try and attach an ite
	 */
	amiga_config_found(cfdata, self, gp, grfprint);
#endif
}
Beispiel #6
0
void
fbwscons_console_init(struct sunfb *sf, int row)
{
	struct rasops_info *ri = &sf->sf_ro;
	long defattr;

	if (CPU_ISSUN4 || romgetcursoraddr(&sf->sf_crowp, &sf->sf_ccolp))
		sf->sf_ccolp = sf->sf_crowp = NULL;
	if (sf->sf_ccolp != NULL)
		ri->ri_ccol = *sf->sf_ccolp;

	if (row < 0) {
		if (sf->sf_crowp != NULL)
			ri->ri_crow = *sf->sf_crowp;
		else
			/* assume last row */
			ri->ri_crow = ri->ri_rows - 1;
	} else {
		/*
		 * If we force the display row, this is because the screen
		 * has been cleared or the font has been changed.
		 * In this case, choose not to keep pointers to the PROM
		 * cursor position, as the values are likely to be inaccurate
		 * upon shutdown...
		 */
		sf->sf_crowp = sf->sf_ccolp = NULL;
		ri->ri_crow = row;
	}

	/*
	 * Scale back rows and columns if the font would not otherwise
	 * fit on this display. Without this we would panic later.
	 */
	if (ri->ri_crow >= ri->ri_rows)
		ri->ri_crow = ri->ri_rows - 1;
	if (ri->ri_ccol >= ri->ri_cols)
		ri->ri_ccol = ri->ri_cols - 1;

	/*
	 * Take care of updating the PROM cursor position as well if we can.
	 */
	if (ri->ri_updatecursor == NULL &&
	    (sf->sf_ccolp != NULL || sf->sf_crowp != NULL))
		ri->ri_updatecursor = fb_updatecursor;

	if (ISSET(ri->ri_caps, WSSCREEN_WSCOLORS))
		ri->ri_ops.alloc_attr(ri,
		    WSCOL_BLACK, WSCOL_WHITE, WSATTR_WSCOLORS, &defattr);
	else
		ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr);

	fb_initwsd(sf);
	wsdisplay_cnattach(&sf->sf_wsd, ri,
	    ri->ri_ccol, ri->ri_crow, defattr);
}
Beispiel #7
0
int
smfb_cnattach(bus_space_tag_t memt, bus_space_tag_t iot, pcitag_t tag,
    pcireg_t id)
{
	long defattr;
	struct rasops_info *ri;
	bus_space_handle_t fbh, mmioh;
	pcireg_t bar;
	int rc, is5xx;

	/* filter out unrecognized devices */
	switch (id) {
	default:
		return ENODEV;
	case PCI_ID_CODE(PCI_VENDOR_SMI, PCI_PRODUCT_SMI_SM712):
		is5xx = 0;
		break;
	case PCI_ID_CODE(PCI_VENDOR_SMI, PCI_PRODUCT_SMI_SM501):
		is5xx = 1;
		break;
	}

	smfbcn.is5xx = is5xx;

	bar = pci_conf_read_early(tag, PCI_MAPREG_START);
	if (PCI_MAPREG_TYPE(bar) != PCI_MAPREG_TYPE_MEM)
		return EINVAL;
	rc = bus_space_map(memt, PCI_MAPREG_MEM_ADDR(bar), 1 /* XXX */,
	    BUS_SPACE_MAP_LINEAR, &fbh);
	if (rc != 0)
		return rc;

	if (smfbcn.is5xx) {
		bar = pci_conf_read_early(tag, PCI_MAPREG_START + 0x04);
		if (PCI_MAPREG_TYPE(bar) != PCI_MAPREG_TYPE_MEM)
			return EINVAL;
		rc = bus_space_map(memt, PCI_MAPREG_MEM_ADDR(bar), 1 /* XXX */,
		    BUS_SPACE_MAP_LINEAR, &mmioh);
		if (rc != 0)
			return rc;
	} else {
		mmioh = fbh;
	}

	rc = smfb_setup(&smfbcn, memt, fbh, memt, mmioh);
	if (rc != 0)
		return rc;

	ri = &smfbcn.ri;
	ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr);
	wsdisplay_cnattach(&smfbcn.wsd, ri, 0, 0, defattr);

	return 0;
}
Beispiel #8
0
int
light_cnattach(struct gio_attach_args *ga)
{

	if (!light_match(NULL, NULL, ga))
		return (ENXIO);

	light_attach_common(&light_console_dc, ga);

	wsdisplay_cnattach(&light_screen, &light_console_dc, 0, 0,
	    LIGHT_ATTR_ENCODE(WSCOL_WHITE, WSCOL_BLACK));

	light_is_console = 1;

	return (0);
}
Beispiel #9
0
/*
 * This gets called if this device is used as the console.
 */
void
amidisplaycc_cninit(struct consdev  * cd)
{
	void  * cookie;
	long    attr;
	int     x;
	int     y;

	/* Yeah, we got the console! */

	/*
	 * This will do the basic stuff we also need.
	 */
	config_console();

	grfcc_probe();

#if NVIEW>0
	viewprobe();
#endif

	/*
	 * Set up wscons to handle the details.
	 * It will then call us back when it needs something
	 * display-specific. It will also set up cn_tab properly,
	 * something which we failed to do at amidisplaycc_cnprobe().
	 */

	/*
	 * The alloc_screen knows to allocate the first screen statically.
	 */
	amidisplaycc_alloc_screen(NULL, &amidisplaycc_screentab[0].wsdescr,
				  &cookie, &x, &y, &attr);
	wsdisplay_cnattach(&amidisplaycc_screentab[0].wsdescr,
			   cookie, x, y, attr);

#if NKBD>0
	/* tell kbd device it is used as console keyboard */
	kbd_cnattach();
#endif
}
Beispiel #10
0
int
pcdisplay_cnattach(bus_space_tag_t iot, bus_space_tag_t memt)
{
	int mono;

	if (pcdisplay_probe_col(iot, memt))
		mono = 0;
	else if (pcdisplay_probe_mono(iot, memt))
		mono = 1;
	else
		return (ENXIO);

	pcdisplay_init(&pcdisplay_console_dc, iot, memt, mono);

	wsdisplay_cnattach(&pcdisplay_scr, &pcdisplay_console_dc,
			   pcdisplay_console_dc.pcs.cursorcol,
			   pcdisplay_console_dc.pcs.cursorrow,
			   FG_LIGHTGREY | BG_BLACK);

	pcdisplayconsole = 1;
	return (0);
}
Beispiel #11
0
int
smfb_cnattach()
{
	long defattr;
	struct rasops_info *ri;
	vaddr_t fbbase;
	int rc;
	extern paddr_t loongson_pci_base;

	/* XXX hardwired fbmem address */
	fbbase = PHYS_TO_XKPHYS(loongson_pci_base + 0x14000000, CCA_NC);

	rc = smfb_setup(&smfbcn, fbbase);
	if (rc != 0)
		return rc;

	ri = &smfbcn.ri;
	ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr);
	wsdisplay_cnattach(&smfbcn.wsd, ri, 0, 0, defattr);

	return 0;
}
Beispiel #12
0
int
newport_cnattach(struct gio_attach_args *ga)
{
	struct rasops_info *ri = &newport_console_screen.scr_ri;
	long defattr = NEWPORT_ATTR_ENCODE(WSCOL_WHITE, WSCOL_BLACK);

	if (!newport_match(NULL, NULL, ga)) {
		return ENXIO;
	}

	newport_attach_common(&newport_console_dc, ga);

	newport_screen.ncols = newport_console_dc.dc_xres / 8;
	newport_screen.nrows = newport_console_dc.dc_yres / 16;

	ri->ri_hw = &newport_console_screen;
	ri->ri_depth = newport_console_dc.dc_depth;
	ri->ri_width = newport_console_dc.dc_xres;
	ri->ri_height = newport_console_dc.dc_yres;
	ri->ri_stride = newport_console_dc.dc_xres; /* XXX */
	ri->ri_flg = RI_CENTER | RI_FULLCLEAR;
	ri->ri_ops.copyrows  = newport_copyrows;
	ri->ri_ops.eraserows = newport_eraserows;
	ri->ri_ops.copycols  = newport_copycols;
	ri->ri_ops.erasecols = newport_erasecols;
	ri->ri_ops.cursor    = newport_cursor_dummy;
	ri->ri_ops.mapchar   = newport_mapchar;
	ri->ri_ops.putchar   = newport_putchar;
	ri->ri_ops.allocattr = newport_allocattr;
	ri->ri_font = newport_console_dc.dc_fontdata;
	newport_console_screen.scr_cookie = &newport_console_dc;

	wsdisplay_cnattach(&newport_screen, ri, 0, 0, defattr);

	newport_is_console = 1;

	return 0;
}
Beispiel #13
0
int
xafb_cnattach(void)
{
	struct xafb_devconfig *dc = &xafb_console_dc;
	struct rasops_info *ri = &dc->dc_ri;
	long defattr;
	int crow = 0;

	if (!xafb_is_console())
		return -1;

	dc->dc_fbpaddr = (paddr_t)0x10000000;
	dc->dc_fbbase = (void *)MIPS_PHYS_TO_KSEG1(dc->dc_fbpaddr);
	dc->dc_reg = (void *)0xb4903000;			/* XXX */
	xafb_common_init(dc);

	crow = 0;			/* XXX current cursor pos */

	(*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
	wsdisplay_cnattach(&xafb_stdscreen, &dc->dc_ri, 0, crow, defattr);

	return 0;
}
Beispiel #14
0
/*
 * Called very early to setup the glass tty as console.
 * Because it's called before the VM system is initialized, virtual memory
 * for the framebuffer can be stolen directly without disturbing anything.
 */
int
legsscninit()
{
    struct legss_screen *ss = &legss_consscr;
    extern vaddr_t virtual_avail;
    vaddr_t ova;
    long defattr;
    struct rasops_info *ri;

    ova = virtual_avail;

    ioaccess(virtual_avail, LEGSS_BASE + LEGSS_VRAM_OFFSET, 1);
    ss->ss_depth = legss_probe_depth(virtual_avail);
    iounaccess(virtual_avail, 1);
    if (ss->ss_depth == 0)
        return 1;

    ioaccess(virtual_avail, LEGSS_BASE + LEGSS_VRAM_OFFSET,
             (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG);
    ss->ss_vram = virtual_avail;
    virtual_avail += (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY);
    virtual_avail = round_page(virtual_avail);

    /* this had better not fail */
    if (legss_setup_screen(ss) != 0) {
        iounaccess(ss->ss_vram,
                   (LEGSS_VISHEIGHT * LEGSS_WIDTH * 32 / NBBY) / VAX_NBPG);
        virtual_avail = ova;
        return 1;
    }

    ri = &ss->ss_ri;
    ri->ri_ops.alloc_attr(ri, 0, 0, 0, &defattr);
    wsdisplay_cnattach(&legss_stdscreen, ri, 0, 0, defattr);

    return 0;
}
Beispiel #15
0
int
hpcfb_cnattach(struct hpcfb_fbconf *fbconf)
{
	struct hpcfb_fbconf __fbconf __attribute__((__unused__));
	long defattr;

	DPRINTF(("%s(%d): hpcfb_cnattach()\n", __FILE__, __LINE__));
#if NBIVIDEO > 0
	if (fbconf == 0) {
		memset(&__fbconf, 0, sizeof(struct hpcfb_fbconf));
		if (bivideo_getcnfb(&__fbconf) != 0)
			return (ENXIO);
		fbconf = &__fbconf;
	}
#endif /* NBIVIDEO > 0 */
	memset(&hpcfb_console_dc, 0, sizeof(struct hpcfb_devconfig));
	if (hpcfb_init(fbconf, &hpcfb_console_dc) != 0)
		return (ENXIO);
	hpcfb_console_dc.dc_state |= HPCFB_DC_CURRENT;

	hpcfb_console_dc.dc_tvram = hpcfb_console_tvram;
	/* clear screen */
	memset(hpcfb_console_tvram, 0, sizeof(hpcfb_console_tvram));
	hpcfb_redraw(&hpcfb_console_dc, 0, hpcfb_console_dc.dc_rows, 1);

	hpcfb_console_wsscreen = hpcfb_stdscreen;
	hpcfb_console_wsscreen.nrows = hpcfb_console_dc.dc_rows;
	hpcfb_console_wsscreen.ncols = hpcfb_console_dc.dc_cols;
	hpcfb_console_wsscreen.capabilities = hpcfb_console_dc.dc_rinfo.ri_caps;
	hpcfb_alloc_attr(&hpcfb_console_dc,
			 WSCOL_WHITE, WSCOL_BLACK, 0, &defattr);
	wsdisplay_cnattach(&hpcfb_console_wsscreen, &hpcfb_console_dc,
	    0, 0, defattr);
	hpcfbconsole = 1;

	return (0);
}
/* EXPORT */ int
vidcvideo_cnattach(vaddr_t addr)
{
	struct fb_devconfig *dc = &vidcvideo_console_dc;
	struct rasops_info *ri;
	long defattr;

	vidcvideo_init();

	/* fetch current framebuffer config */
	vidcvideo_getdevconfig(videomemory.vidm_vbase,
			videomemory.vidm_size,
		       	dc);

	dc->dc_vd.active = NULL;
	vidcvideoinit_screen(dc, &dc->dc_console, 1, &defattr);

	ri = &(dc->dc_console.scr_ri);
	ri->ri_hw = &dc->dc_console;
	dc->dc_console.scr_cookie = dc;

	(*ri->ri_ops.allocattr)(ri,
				WS_DEFAULT_FG, /* fg */
				WS_DEFAULT_BG, /* bg */
				0,           /* wsattrs */
				&defattr);

	wsdisplay_cnattach(&vidcvideo_stdscreen,
			   ri,   /* emulcookie */
		       	   0, 0, /* cursor position */
			   defattr);
	
	vidcvideo_is_console = true;

	return 0;
}
Beispiel #17
0
int
newport_cnattach(struct gio_attach_args *ga)
{
	long defattr = NEWPORT_ATTR_ENCODE(WSCOL_WHITE, WSCOL_BLACK);
	const struct wsscreen_descr *screen;

	if (!newport_match(NULL, NULL, ga)) {
		return ENXIO;
	}

	newport_attach_common(&newport_console_dc, ga);

	if (newport_console_dc.dc_xres >= 1280 &&
	    newport_console_dc.dc_yres >= 1024)
		screen = &newport_screen_1280x1024;
	else
		screen = &newport_screen_1024x768;

	wsdisplay_cnattach(screen, &newport_console_dc, 0, 0, defattr);

	newport_is_console = 1;

	return 0;
}
Beispiel #18
0
void
radeondrm_attachhook(void *xsc)
{
	struct radeon_device	*rdev = xsc;
	int			 r, acpi_status;

	/* radeon_device_init should report only fatal error
	 * like memory allocation failure or iomapping failure,
	 * or memory manager initialization failure, it must
	 * properly initialize the GPU MC controller and permit
	 * VRAM allocation
	 */
	r = radeon_device_init(rdev, rdev->ddev);
	if (r) {
		printf(": Fatal error during GPU init\n");
		radeon_fatal_error = 1;
		radeondrm_forcedetach(rdev);
		return;
	}

	/* Again modeset_init should fail only on fatal error
	 * otherwise it should provide enough functionalities
	 * for shadowfb to run
	 */
	r = radeon_modeset_init(rdev);
	if (r)
		printf("Fatal error during modeset init\n");

	/* Call ACPI methods: require modeset init
	 * but failure is not fatal
	 */
	if (!r) {
		acpi_status = radeon_acpi_init(rdev);
		if (acpi_status)
			DRM_DEBUG("Error during ACPI methods call\n");
	}

{
	struct wsemuldisplaydev_attach_args aa;
	struct rasops_info *ri = &rdev->ro;

	if (ri->ri_bits == NULL)
		return;

#ifdef __sparc64__
	fbwscons_setcolormap(&rdev->sf, radeondrm_setcolor);
#endif
	drm_fb_helper_restore();

#ifndef __sparc64__
	ri->ri_flg = RI_CENTER | RI_VCONS | RI_WRONLY;
	rasops_init(ri, 160, 160);

	ri->ri_hw = rdev;
#else
	ri = &rdev->sf.sf_ro;
#endif

	radeondrm_stdscreen.capabilities = ri->ri_caps;
	radeondrm_stdscreen.nrows = ri->ri_rows;
	radeondrm_stdscreen.ncols = ri->ri_cols;
	radeondrm_stdscreen.textops = &ri->ri_ops;
	radeondrm_stdscreen.fontwidth = ri->ri_font->fontwidth;
	radeondrm_stdscreen.fontheight = ri->ri_font->fontheight;

	aa.console = rdev->console;
	aa.scrdata = &radeondrm_screenlist;
	aa.accessops = &radeondrm_accessops;
	aa.accesscookie = ri;
	aa.defaultscreens = 0;

	if (rdev->console) {
		long defattr;

		ri->ri_ops.alloc_attr(ri->ri_active, 0, 0, 0, &defattr);
		wsdisplay_cnattach(&radeondrm_stdscreen, ri->ri_active,
		    ri->ri_ccol, ri->ri_crow, defattr);
	}

	/*
	 * Now that we've taken over the console, disable decoding of
	 * VGA legacy addresses, and opt out of arbitration.
	 */
	radeon_vga_set_state(rdev, false);
	pci_disable_legacy_vga(&rdev->dev);

	printf("%s: %dx%d\n", rdev->dev.dv_xname, ri->ri_width, ri->ri_height);

	config_found_sm(&rdev->dev, &aa, wsemuldisplaydevprint,
	    wsemuldisplaydevsubmatch);
}
}
Beispiel #19
0
static void
cg14_setup_wsdisplay(struct cgfourteen_softc *sc, int is_cons)
{
	struct wsemuldisplaydev_attach_args aa;
	struct rasops_info *ri;
	long defattr;

 	sc->sc_defaultscreen_descr = (struct wsscreen_descr){
		"default",
		0, 0,
		NULL,
		8, 16,
		WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
		NULL
	};
	sc->sc_screens[0] = &sc->sc_defaultscreen_descr;
	sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens};
	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
	vcons_init(&sc->sc_vd, sc, &sc->sc_defaultscreen_descr,
	    &cg14_accessops);
	sc->sc_vd.init_screen = cg14_init_screen;

	ri = &sc->sc_console_screen.scr_ri;

	if (is_cons) {
		vcons_init_screen(&sc->sc_vd, &sc->sc_console_screen, 1,
		    &defattr);
		sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;

		sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
		sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
		sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
		sc->sc_defaultscreen_descr.ncols = ri->ri_cols;
		wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
		    defattr);
	} else {
		/*
		 * since we're not the console we can postpone the rest
		 * until someone actually allocates a screen for us
		 */
	}

	cg14_init_cmap(sc);

	aa.console = is_cons;
	aa.scrdata = &sc->sc_screenlist;
	aa.accessops = &cg14_accessops;
	aa.accesscookie = &sc->sc_vd;

	config_found(sc->sc_dev, &aa, wsemuldisplaydevprint);
}

static void
cg14_init_cmap(struct cgfourteen_softc *sc)
{
	int i, j = 0;

	for (i = 0; i < 256; i++) {

		sc->sc_cmap.cm_map[i][3] = rasops_cmap[j];
		sc->sc_cmap.cm_map[i][2] = rasops_cmap[j + 1];
		sc->sc_cmap.cm_map[i][1] = rasops_cmap[j + 2];
		j += 3;
	}
	cg14_load_hwcmap(sc, 0, 256);
}

static int
cg14_putcmap(struct cgfourteen_softc *sc, struct wsdisplay_cmap *cm)
{
	u_int index = cm->index;
	u_int count = cm->count;
	int i, error;
	u_char rbuf[256], gbuf[256], bbuf[256];

	if (cm->index >= 256 || cm->count > 256 ||
	    (cm->index + cm->count) > 256)
		return EINVAL;
	error = copyin(cm->red, &rbuf[index], count);
	if (error)
		return error;
	error = copyin(cm->green, &gbuf[index], count);
	if (error)
		return error;
	error = copyin(cm->blue, &bbuf[index], count);
	if (error)
		return error;

	for (i = 0; i < count; i++) {
		sc->sc_cmap.cm_map[index][3] = rbuf[index];
		sc->sc_cmap.cm_map[index][2] = gbuf[index];
		sc->sc_cmap.cm_map[index][1] = bbuf[index];
		
		index++;
	}
	cg14_load_hwcmap(sc, 0, 256);
	return 0;
}
Beispiel #20
0
/*
 * Attach a display.  We need to notice if it is the console, too.
 */
static void
p9100_sbus_attach(struct device *parent, struct device *self, void *args)
{
	struct p9100_softc *sc = device_private(self);
	struct sbus_attach_args *sa = args;
	struct fbdevice *fb = &sc->sc_fb;
	int isconsole;
	int node;
	int i, j;
	uint8_t ver;

#if NWSDISPLAY > 0
	struct wsemuldisplaydev_attach_args aa;
	struct rasops_info *ri;
	unsigned long defattr;
#endif

	sc->sc_last_offset = 0xffffffff;

	/* Remember cookies for p9100_mmap() */
	sc->sc_bustag = sa->sa_bustag;
	sc->sc_ctl_paddr = sbus_bus_addr(sa->sa_bustag,
		sa->sa_reg[0].oa_space, sa->sa_reg[0].oa_base);
	sc->sc_ctl_psize = 0x8000;/*(bus_size_t)sa->sa_reg[0].oa_size;*/

	sc->sc_cmd_paddr = sbus_bus_addr(sa->sa_bustag,
		sa->sa_reg[1].oa_space, sa->sa_reg[1].oa_base);
	sc->sc_cmd_psize = (bus_size_t)sa->sa_reg[1].oa_size;

	sc->sc_fb_paddr = sbus_bus_addr(sa->sa_bustag,
		sa->sa_reg[2].oa_space, sa->sa_reg[2].oa_base);
	sc->sc_fb_psize = (bus_size_t)sa->sa_reg[2].oa_size;

	fb->fb_driver = &p9100fbdriver;
	fb->fb_device = &sc->sc_dev;
	fb->fb_flags = device_cfdata(&sc->sc_dev)->cf_flags & FB_USERMASK;
#ifdef PNOZZ_EMUL_CG3
	fb->fb_type.fb_type = FBTYPE_SUN3COLOR;
#else
	fb->fb_type.fb_type = FBTYPE_P9100;
#endif
	fb->fb_pixels = NULL;

	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;

	node = sa->sa_node;
	isconsole = fb_is_console(node);
	if (!isconsole) {
		aprint_normal("\n");
		aprint_error_dev(self, "fatal error: PROM didn't configure device\n");
		return;
	}

	/*
	 * When the ROM has mapped in a p9100 display, the address
	 * maps only the video RAM, so in any case we have to map the
	 * registers ourselves.  We only need the video RAM if we are
	 * going to print characters via rconsole.
	 */
	if (sbus_bus_map(sc->sc_bustag,
			 sa->sa_reg[0].oa_space,
			 sa->sa_reg[0].oa_base,
			 /*
			  * XXX for some reason the SBus resources don't cover
			  * all registers, so we just map what we need
			  */
			 /*sc->sc_ctl_psize*/ 0x8000,
			 /*BUS_SPACE_MAP_LINEAR*/0, &sc->sc_ctl_memh) != 0) {
		aprint_error_dev(self, "cannot map control registers\n");
		return;
	}

	if (sa->sa_npromvaddrs != 0)
		fb->fb_pixels = (void *)sa->sa_promvaddrs[0];

	if (fb->fb_pixels == NULL) {
		if (sbus_bus_map(sc->sc_bustag,
				sa->sa_reg[2].oa_space,
				sa->sa_reg[2].oa_base,
				sc->sc_fb_psize,
				BUS_SPACE_MAP_LINEAR, &sc->sc_fb_memh) != 0) {
			aprint_error_dev(self, "cannot map framebuffer\n");
			return;
		}
		fb->fb_pixels = (char *)sc->sc_fb_memh;
	} else {
		sc->sc_fb_memh = (bus_space_handle_t) fb->fb_pixels;
	}

	i = p9100_ctl_read_4(sc, 0x0004);
	switch ((i >> 26) & 7) {
	    case 5: fb->fb_type.fb_depth = 32; break;
	    case 7: fb->fb_type.fb_depth = 24; break;
	    case 3: fb->fb_type.fb_depth = 16; break;
	    case 2: fb->fb_type.fb_depth = 8; break;
	    default: {
		panic("pnozz: can't determine screen depth (0x%02x)", i);
	    }
	}
	sc->sc_depth = (fb->fb_type.fb_depth >> 3);

	/* XXX for some reason I get a kernel trap with this */
	sc->sc_width = prom_getpropint(node, "width", 800);
	sc->sc_height = prom_getpropint(node, "height", 600);

	sc->sc_stride = prom_getpropint(node, "linebytes", sc->sc_width *
	    (fb->fb_type.fb_depth >> 3));

	/* check the RAMDAC */
	ver = p9100_ramdac_read_ctl(sc, DAC_VERSION);

	p9100_init_engine(sc);

	fb_setsize_obp(fb, fb->fb_type.fb_depth, sc->sc_width, sc->sc_height,
	    node);

	sbus_establish(&sc->sc_sd, &sc->sc_dev);
	bus_intr_establish(sc->sc_bustag, sa->sa_pri, IPL_BIO,
	    p9100_intr, sc);

	fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
	printf(": rev %d / %x, %dx%d, depth %d mem %x",
	       (i & 7), ver, fb->fb_type.fb_width, fb->fb_type.fb_height,
	       fb->fb_type.fb_depth, (unsigned int)sc->sc_fb_psize);

	fb->fb_type.fb_cmsize = prom_getpropint(node, "cmsize", 256);
	if ((1 << fb->fb_type.fb_depth) != fb->fb_type.fb_cmsize)
		printf(", %d entry colormap", fb->fb_type.fb_cmsize);

	/* Initialize the default color map. */
	/*bt_initcmap(&sc->sc_cmap, 256);*/
	j = 0;
	for (i = 0; i < 256; i++) {
		sc->sc_cmap.cm_map[i][0] = rasops_cmap[j];
		j++;
		sc->sc_cmap.cm_map[i][1] = rasops_cmap[j];
		j++;
		sc->sc_cmap.cm_map[i][2] = rasops_cmap[j];
		j++;
	}
	p9100loadcmap(sc, 0, 256);

	/* make sure we are not blanked */
	if (isconsole)
		p9100_set_video(sc, 1);

	if (shutdownhook_establish(p9100_shutdown, sc) == NULL) {
		panic("%s: could not establish shutdown hook",
		      device_xname(&sc->sc_dev));
	}

	if (isconsole) {
		printf(" (console)\n");
#ifdef RASTERCONSOLE
		/*p9100loadcmap(sc, 255, 1);*/
		fbrcons_init(fb);
#endif
	} else
		printf("\n");

#if NWSDISPLAY > 0
	wsfont_init();

	vcons_init(&sc->vd, sc, &p9100_defscreendesc, &p9100_accessops);
	sc->vd.init_screen = p9100_init_screen;

	vcons_init_screen(&sc->vd, &p9100_console_screen, 1, &defattr);
	p9100_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;

	sc->sc_bg = (defattr >> 16) & 0xff;
	p9100_clearscreen(sc);

	ri = &p9100_console_screen.scr_ri;

	p9100_defscreendesc.nrows = ri->ri_rows;
	p9100_defscreendesc.ncols = ri->ri_cols;
	p9100_defscreendesc.textops = &ri->ri_ops;
	p9100_defscreendesc.capabilities = ri->ri_caps;

	if(isconsole) {
		wsdisplay_cnattach(&p9100_defscreendesc, ri, 0, 0, defattr);
	}

	aa.console = isconsole;
	aa.scrdata = &p9100_screenlist;
	aa.accessops = &p9100_accessops;
	aa.accesscookie = &sc->vd;

	config_found(self, &aa, wsemuldisplaydevprint);
#endif
	/* cursor sprite handling */
	p9100_init_cursor(sc);

	/* attach the fb */
	fb_attach(fb, isconsole);

	/* register with power management */
	sc->sc_video = 1;
	sc->sc_powerstate = PWR_RESUME;
	powerhook_establish(device_xname(&sc->sc_dev), p9100_power_hook, sc);

#if NTCTRL > 0
	/* register callback for external monitor status change */
	tadpole_register_callback(p9100_set_extvga, sc);
#endif
}
Beispiel #21
0
static void
igmafb_attach(device_t parent, device_t self, void *aux)
{
    struct igmafb_softc *sc = device_private(self);
    struct igma_attach_args *iaa = (struct igma_attach_args *)aux;
    struct rasops_info *ri;
    prop_dictionary_t dict;
    bool is_console;
    unsigned long defattr;
    struct wsemuldisplaydev_attach_args waa;

    sc->sc_dev = self;

    aprint_normal("\n");

    dict = device_properties(self);
    prop_dictionary_get_bool(dict, "is_console", &is_console);
    if (iaa->iaa_console)
        is_console = true;

    sc->sc_chip = iaa->iaa_chip;

    sc->sc_fbaddr = bus_space_vaddr(sc->sc_chip.gmt, sc->sc_chip.gmh);
    sc->sc_fbsize = 16 * 1024 * 1024;

    igmafb_guess_size(sc, &sc->sc_width, &sc->sc_height);
    sc->sc_depth = 32;
    sc->sc_stride = (sc->sc_width*4 + 511)/512*512;

    aprint_normal("%s: %d x %d, %d bit, stride %d\n", device_xname(self),
                  sc->sc_width, sc->sc_height, sc->sc_depth, sc->sc_stride);

    aprint_normal("%s: %d MB video memory at 0x%p\n", device_xname(self),
                  (int)sc->sc_fbsize >> 20, (void *)sc->sc_chip.gmb);

    sc->sc_vga_save = kmem_alloc(256*1024, KM_SLEEP);

    igmafb_get_brightness(sc, &sc->sc_brightness);
    igmafb_get_brightness_max(sc, &sc->sc_brightness_max);
    sc->sc_backlight = sc->sc_brightness != 0;

    sc->sc_defaultscreen_descr = (struct wsscreen_descr) {
        "default",
        0, 0,
        NULL,
        8, 16,
        WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
        NULL
    };
    sc->sc_screens[0] = &sc->sc_defaultscreen_descr;
    sc->sc_screenlist = (struct wsscreen_list) {
        1, sc->sc_screens
    };

    vcons_init(&sc->vd, sc, &sc->sc_defaultscreen_descr,
               &igmafb_accessops);
    sc->vd.init_screen = igmafb_init_screen;

    /* enable hardware display */
    igmafb_set_mode(sc, true);

    ri = &sc->sc_console_screen.scr_ri;

    if (is_console) {
        vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
                          &defattr);

        sc->sc_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC
                                           | VCONS_NO_COPYROWS | VCONS_NO_COPYCOLS;
        vcons_redraw_screen(&sc->sc_console_screen);

        sc->sc_defaultscreen_descr.textops = &ri->ri_ops;
        sc->sc_defaultscreen_descr.capabilities = ri->ri_caps;
        sc->sc_defaultscreen_descr.nrows = ri->ri_rows;
        sc->sc_defaultscreen_descr.ncols = ri->ri_cols;

        wsdisplay_cnattach(&sc->sc_defaultscreen_descr, ri, 0, 0,
                           defattr);
        vcons_replay_msgbuf(&sc->sc_console_screen);
    } else {
        if (sc->sc_console_screen.scr_ri.ri_rows == 0) {
            /* do some minimal setup to avoid weirdness later */
            vcons_init_screen(&sc->vd, &sc->sc_console_screen, 1,
                              &defattr);
        } else
            (*ri->ri_ops.allocattr)(ri, 0, 0, 0, &defattr);
    }

    waa.console = is_console;
    waa.scrdata = &sc->sc_screenlist;
    waa.accessops = &igmafb_accessops;
    waa.accesscookie = &sc->vd;

    config_found(sc->sc_dev, &waa, wsemuldisplaydevprint);
}

/*
 * wsdisplay accessops
 */

static int
igmafb_ioctl(void *v, void *vs, u_long cmd, void *data, int flags,
             struct lwp *l)
{
    struct vcons_data *vd = v;
    struct igmafb_softc *sc = vd->cookie;
    struct wsdisplay_fbinfo *wdf;
    struct vcons_screen *ms = vd->active;
    struct wsdisplayio_fbinfo *fbi;
    struct wsdisplay_param *param;
    int val;

    switch (cmd) {
    case WSDISPLAYIO_GTYPE:
        *(u_int *)data = WSDISPLAY_TYPE_PCIMISC;
        return 0;
    case WSDISPLAYIO_GINFO:
        if (ms == NULL)
            return ENODEV;
        wdf = data;
        wdf->width  = ms->scr_ri.ri_width;
        wdf->height = ms->scr_ri.ri_height;
        wdf->depth  = ms->scr_ri.ri_depth;
        wdf->cmsize = 256; /* XXX */
        return 0;
    case WSDISPLAYIO_LINEBYTES:
        if (ms == NULL)
            return ENODEV;
        *(u_int *)data = ms->scr_ri.ri_stride;
        return 0;
    case WSDISPLAYIO_GET_FBINFO:
        fbi = data;
        return wsdisplayio_get_fbinfo(&ms->scr_ri, fbi);
    case WSDISPLAYIO_SVIDEO:
        val = (*(u_int *)data) != WSDISPLAYIO_VIDEO_OFF;
        sc->sc_backlight = val;
        if (val)
            igmafb_set_brightness(sc, sc->sc_brightness);
        else
            igmafb_set_brightness(sc, 0);
        return 0;
    case WSDISPLAYIO_GETPARAM:
        param = (struct wsdisplay_param *)data;
        switch (param->param) {
        case WSDISPLAYIO_PARAM_BRIGHTNESS:
            param->min = 0;
            param->max = 255;
            if (sc->sc_backlight)
                igmafb_get_brightness(sc, &val);
            else
                val = sc->sc_brightness;
            val = val * 255 / sc->sc_brightness_max;
            param->curval = val;
            return 0;
        case WSDISPLAYIO_PARAM_BACKLIGHT:
            param->min = 0;
            param->max = 1;
            param->curval = sc->sc_backlight;
            return 0;
        }
        return EPASSTHROUGH;
    case WSDISPLAYIO_SETPARAM:
        param = (struct wsdisplay_param *)data;
        switch (param->param) {
        case WSDISPLAYIO_PARAM_BRIGHTNESS:
            val = param->curval;
            if (val < 0)
                val = 0;
            if (val > 255)
                val = 255;
            val = val * sc->sc_brightness_max / 255;
            sc->sc_brightness = val;
            if (sc->sc_backlight)
                igmafb_set_brightness(sc, val);
            return 0;
        case WSDISPLAYIO_PARAM_BACKLIGHT:
            val = param->curval;
            sc->sc_backlight = val;
            if (val)
                igmafb_set_brightness(sc, sc->sc_brightness);
            else
                igmafb_set_brightness(sc, 0);
            return 0;
        }
        return EPASSTHROUGH;
    }

    return EPASSTHROUGH;
}

static paddr_t
igmafb_mmap(void *v, void *vs, off_t offset, int prot)
{
    struct vcons_data *vd = v;
    struct igmafb_softc *sc = vd->cookie;

    if ((offset & PAGE_MASK) != 0)
        return -1;

    if (offset < 0 || offset >= sc->sc_fbsize)
        return -1;

    return bus_space_mmap(sc->sc_chip.gmt, sc->sc_chip.gmb, offset, prot,
                          BUS_SPACE_MAP_LINEAR);
}

static void
igmafb_pollc(void *v, int on)
{
    struct vcons_data *vd = v;
    struct igmafb_softc *sc = vd->cookie;

    if (sc == NULL)
        return;
    if (sc->sc_console_screen.scr_vd == NULL)
        return;

    if (on)
        vcons_enable_polling(&sc->vd);
    else
        vcons_disable_polling(&sc->vd);
}

static void
igmafb_init_screen(void *cookie, struct vcons_screen *scr,
                   int existing, long *defattr)
{
    struct igmafb_softc *sc = cookie;
    struct rasops_info *ri = &scr->scr_ri;

    memset(ri, 0, sizeof(struct rasops_info));

    ri->ri_depth = sc->sc_depth;
    ri->ri_width = sc->sc_width;
    ri->ri_height = sc->sc_height;
    ri->ri_stride = sc->sc_stride;
    ri->ri_flg = RI_CENTER | RI_FULLCLEAR;

    ri->ri_bits = (char *)sc->sc_fbaddr;

    if (existing) {
        ri->ri_flg |= RI_CLEAR;
    }

    switch (sc->sc_depth) {
    case 32:
        ri->ri_rnum = 8;
        ri->ri_gnum = 8;
        ri->ri_bnum = 8;
        ri->ri_rpos = 16;
        ri->ri_gpos = 8;
        ri->ri_bpos = 0;
        break;
    }

    rasops_init(ri, 0, 0);
    ri->ri_caps = WSSCREEN_WSCOLORS;

    rasops_reconfig(ri, sc->sc_height / ri->ri_font->fontheight,
                    sc->sc_width / ri->ri_font->fontwidth);

    ri->ri_hw = scr;
}

static void
igmafb_guess_size(struct igmafb_softc *sc, int *widthp, int *heightp)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    int pipe = cd->use_pipe;
    u_int32_t r;

    r = co->read_reg(cd, PIPE_HTOTAL(pipe));
    *widthp = PIPE_HTOTAL_GET_ACTIVE(r);
    r = co->read_reg(cd, PIPE_VTOTAL(pipe));
    *heightp = PIPE_VTOTAL_GET_ACTIVE(r);

    aprint_normal("%s: vga active size %d x %d\n",
                  device_xname(sc->sc_dev),
                  *widthp, *heightp);

    if (*widthp < 640 || *heightp < 400) {
        r = co->read_reg(cd, PF_WINSZ(pipe));
        *widthp  = PF_WINSZ_GET_WIDTH(r);
        *heightp = PF_WINSZ_GET_HEIGHT(r);

        aprint_normal("%s: window size %d x %d\n",
                      device_xname(sc->sc_dev),
                      *widthp, *heightp);
    }

    if (*widthp  < 640) *widthp  = 640;
    if (*heightp < 400) *heightp = 400;
}

static void
igmafb_set_mode(struct igmafb_softc *sc, bool enable)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    int pipe = cd->use_pipe;
    u_int32_t r;
    u_int8_t b;
    int i;

    if (enable) {
        /* disable VGA machinery */
        b = co->read_vga(cd, 0x01);
        co->write_vga(cd, 0x01, b | 0x20);

        /* disable VGA compatible display */
        r = co->read_reg(cd, sc->sc_chip.vga_cntrl);
        co->write_reg(cd, sc->sc_chip.vga_cntrl, r | VGA_CNTRL_DISABLE);

        /* save VGA memory */
        memcpy(sc->sc_vga_save, sc->sc_fbaddr, 256*1024);

        /* configure panel fitter */
        co->write_reg(cd, PF_WINPOS(pipe),
                      PF_WINPOS_VAL(0, 0));
        co->write_reg(cd, PF_WINSZ(pipe),
                      PF_WINSZ_VAL(sc->sc_width, sc->sc_height));

        /* pipe size */
        co->write_reg(cd, PIPE_SRCSZ(pipe),
                      PIPE_SRCSZ_VAL(sc->sc_width, sc->sc_height));

        /* enable pipe */
        co->write_reg(cd, PIPE_CONF(pipe),
                      PIPE_CONF_ENABLE | PIPE_CONF_8BPP);

        /* configure planes */
        r = co->read_reg(cd, PRI_CTRL(pipe));
        r &= ~(PRI_CTRL_PIXFMTMSK | PRI_CTRL_TILED);
        r |= PRI_CTRL_ENABLE | PRI_CTRL_BGR;
        co->write_reg(cd, PRI_CTRL(pipe), r | cd->pri_cntrl);
        co->write_reg(cd, PRI_LINOFF(pipe), 0);
        co->write_reg(cd, PRI_STRIDE(pipe), sc->sc_stride);
        co->write_reg(cd, PRI_SURF(pipe), 0);
        co->write_reg(cd, PRI_TILEOFF(pipe), 0);

        if (cd->quirks & IGMA_PLANESTART_QUIRK)
            igmafb_planestart_quirk(sc);

        if (cd->quirks & IGMA_PFITDISABLE_QUIRK)
            igmafb_pfitdisable_quirk(sc);
    } else {
        /* disable planes */
        co->write_reg(cd, PRI_CTRL(pipe), 0 | cd->pri_cntrl);
        co->write_reg(cd, PRI_LINOFF(pipe), 0);
        co->write_reg(cd, PRI_STRIDE(pipe), 2560);
        co->write_reg(cd, PRI_SURF(pipe), 0);
        co->write_reg(cd, PRI_TILEOFF(pipe), 0);

        /* pipe size */
        co->write_reg(cd, PIPE_SRCSZ(pipe),
                      PIPE_SRCSZ_VAL(720,400));

        /* disable pipe */
        co->write_reg(cd, PIPE_CONF(pipe), 0);
        for (i=0; i<10; ++i) {
            delay(10);
            if ((co->read_reg(cd, PIPE_CONF(pipe)) & PIPE_CONF_STATE) == 0)
                break;
        }

        /* workaround before enabling VGA */
        r = co->read_reg(cd, 0x42000);
        co->write_reg(cd, 0x42000, (r & 0x1fffffff) | 0xa0000000);
        r = co->read_reg(cd, 0x42004);
        co->write_reg(cd, 0x42004, (r & 0xfbffffff) | 0x00000000);

        /* configure panel fitter */
        co->write_reg(cd, PF_WINPOS(pipe),
                      PF_WINPOS_VAL(0, 0));
        co->write_reg(cd, PF_WINSZ(pipe),
                      PF_WINSZ_VAL(sc->sc_width, sc->sc_height));

        /* enable VGA compatible display */
        r = co->read_reg(cd, sc->sc_chip.vga_cntrl);
        co->write_reg(cd, sc->sc_chip.vga_cntrl, r & ~VGA_CNTRL_DISABLE);

        /* enable VGA machinery */
        b = co->read_vga(cd, 0x01);
        co->write_vga(cd, 0x01, b & ~0x20);

        /* restore VGA memory */
        memcpy(sc->sc_fbaddr, sc->sc_vga_save, 256*1024);

        /* enable pipe again */
        co->write_reg(cd, PIPE_CONF(pipe),
                      PIPE_CONF_ENABLE | PIPE_CONF_6BPP | PIPE_CONF_DITHER);
    }
}

static void
igmafb_planestart_quirk(struct igmafb_softc *sc)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    int pipe = cd->use_pipe;
    u_int32_t cntrl, fwbcl;

    /* disable self refresh */
    fwbcl = co->read_reg(cd, FW_BLC_SELF);
    co->write_reg(cd, FW_BLC_SELF, fwbcl & ~FW_BLC_SELF_EN);

    cntrl = co->read_reg(cd, CUR_CNTR(pipe));
    co->write_reg(cd, CUR_CNTR(pipe), 1<<5 | 0x07);

    /* "wait for vblank" */
    delay(40000);

    co->write_reg(cd, CUR_CNTR(pipe), cntrl);
    co->write_reg(cd, CUR_BASE(pipe),
                  co->read_reg(cd, CUR_BASE(pipe)));

    co->write_reg(cd, FW_BLC_SELF, fwbcl);
}

static void
igmafb_pfitdisable_quirk(struct igmafb_softc *sc)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    u_int32_t r;

    /* disable i965 panel fitter */
    r = co->read_reg(cd, PF_CTRL_I965);
    co->write_reg(cd, PF_CTRL_I965, r & ~PF_ENABLE);
}

static void
igmafb_get_brightness_max(struct igmafb_softc *sc, int *valp)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    u_int32_t r, f;

    r = co->read_reg(cd, cd->backlight_cntrl);
    f = BACKLIGHT_GET_FREQ(r);
    if (f == 0) {
        r = co->read_reg(cd, RAWCLK_FREQ);
        f = r * 1000000 / (200 * 128);
        if (f == 0 || f > 32767)
            f = 125 * 100000 / (200 * 128);
    }

    *valp = f;
}

static void
igmafb_get_brightness(struct igmafb_softc *sc, int *valp)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    u_int32_t r, v;

    r = co->read_reg(cd, cd->backlight_cntrl);
    v = BACKLIGHT_GET_CYCLE(r);
    *valp = v;
}

static void
igmafb_set_brightness(struct igmafb_softc *sc, int val)
{
    const struct igma_chip *cd = &sc->sc_chip;
    const struct igma_chip_ops *co = cd->ops;
    u_int32_t r, f, l;

    r = co->read_reg(cd, cd->backlight_cntrl);
    f = BACKLIGHT_GET_FREQ(r);
    l = BACKLIGHT_GET_LEGACY(r);

    co->write_reg(cd, cd->backlight_cntrl,
                  BACKLIGHT_VAL(f,l,val));
}
Beispiel #22
0
void
bwtwoattach(struct bwtwo_softc *sc, const char *name, int isconsole)
{
	struct fbdevice *fb = &sc->sc_fb;
	int isoverlay;
#if NWSDISPLAY > 0
	struct wsemuldisplaydev_attach_args aa;
	struct rasops_info *ri = &bw2_console_screen.scr_ri;
	unsigned long defattr = 0;
#endif

	/* Fill in the remaining fbdevice values */
	fb->fb_driver = &bwtwofbdriver;
	fb->fb_device = sc->sc_dev;
	fb->fb_type.fb_type = FBTYPE_SUN2BW;
	fb->fb_type.fb_cmsize = 0;
	fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
	printf(": %s, %d x %d", name,
	       fb->fb_type.fb_width, fb->fb_type.fb_height);

	/* Are we an overlay bw2? */
	if ((fb->fb_flags & FB_PFOUR) == 0 || (sc->sc_ovtype == BWO_NONE))
		isoverlay = 0;
	else
		isoverlay = 1;

	/* Insure video is enabled */
	sc->sc_set_video(sc, 1);

	if (isconsole) {
		printf(" (console)\n");
#ifdef RASTERCONSOLE
		/*
		 * XXX rcons doesn't seem to work properly on the overlay
		 * XXX plane.  This is a temporary kludge until someone
		 * XXX fixes it.
		 */
		if (!isoverlay)
			fbrcons_init(fb);
#endif
	} else
		printf("\n");

	if (isoverlay) {
		const char *ovnam;

		switch (sc->sc_ovtype) {
		case BWO_CGFOUR:
			ovnam = "cgfour";
			break;

		case BWO_CGEIGHT:
			ovnam = "cgeight";
			break;

		default:
			ovnam = "unknown";
			break;
		}
		printf("%s: %s overlay plane\n",
		    device_xname(sc->sc_dev), ovnam);
	}

	/*
	 * If we're on an overlay plane of a color framebuffer,
	 * then we don't force the issue in fb_attach() because
	 * we'd like the color framebuffer to actually be the
	 * "console framebuffer".  We're only around to speed
	 * up rconsole.
	 */
	if (isoverlay)
		fb_attach(fb, 0);
	else
		fb_attach(fb, isconsole);

#if NWSDISPLAY > 0
	sc->sc_width = fb->fb_type.fb_width;
	sc->sc_stride = fb->fb_type.fb_width/8;
	sc->sc_height = fb->fb_type.fb_height;

	/* setup rasops and so on for wsdisplay */
	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;

	vcons_init(&sc->vd, sc, &bwtwo_defaultscreen, &bwtwo_accessops);
	sc->vd.init_screen = bwtwo_init_screen;

	if(isconsole && !isoverlay) {
		/* we mess with bw2_console_screen only once */
		vcons_init_screen(&sc->vd, &bw2_console_screen, 1,
		    &defattr);
		bw2_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;

		bwtwo_defaultscreen.textops = &ri->ri_ops;
		bwtwo_defaultscreen.capabilities = ri->ri_caps;
		bwtwo_defaultscreen.nrows = ri->ri_rows;
		bwtwo_defaultscreen.ncols = ri->ri_cols;
		sc->vd.active = &bw2_console_screen;
		wsdisplay_cnattach(&bwtwo_defaultscreen, ri, 0, 0, defattr);
	} else {
		/* 
		 * we're not the console so we just clear the screen and don't 
		 * set up any sort of text display
		 */
		if (bwtwo_defaultscreen.textops == NULL) {
			/* 
			 * ugly, but...
			 * we want the console settings to win, so we only
			 * touch anything when we find an untouched screen
			 * definition. In this case we fill it from fb to
			 * avoid problems in case no bwtwo is the console
			 */
			bwtwo_defaultscreen.textops = &ri->ri_ops;
			bwtwo_defaultscreen.capabilities = ri->ri_caps;
			bwtwo_defaultscreen.nrows = ri->ri_rows;
			bwtwo_defaultscreen.ncols = ri->ri_cols;
		}
	}

	aa.scrdata = &bwtwo_screenlist;
	if (isoverlay)
		aa.console = 0;
	else
		aa.console = isconsole;
	aa.accessops = &bwtwo_accessops;
	aa.accesscookie = &sc->vd;
	config_found(sc->sc_dev, &aa, wsemuldisplaydevprint);
#endif

}
Beispiel #23
0
static void
zx_attach(device_t parent, device_t self, void *args)
{
	struct zx_softc *sc;
	struct sbus_attach_args *sa;
	bus_space_handle_t bh;
	bus_space_tag_t bt;
	struct fbdevice *fb;
#if NWSDISPLAY > 0
	struct wsemuldisplaydev_attach_args aa;
	struct rasops_info *ri = &zx_console_screen.scr_ri;
	unsigned long defattr;
#endif
	int isconsole, width, height;

	sc = device_private(self);
	sc->sc_dv = self;

	sa = args;
	fb = &sc->sc_fb;
	bt = sa->sa_bustag;
	sc->sc_bt = bt;
	sc->sc_paddr = sbus_bus_addr(bt, sa->sa_slot, sa->sa_offset);

	if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_SS0,
	    0x800000, BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_LARGE, &bh) != 0) {
		aprint_error_dev(self, "can't map bits\n");
		return;
	}
	fb->fb_pixels = (void *)bus_space_vaddr(bt, bh);
	sc->sc_pixels = (uint32_t *)fb->fb_pixels;

	if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LC_SS0_USR,
	    PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
		aprint_error_dev(self, "can't map zc\n");
		return;
	}

	sc->sc_bhzc = bh;

	if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS0,
	    PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
		aprint_error_dev(self, "can't map ld/ss0\n");
		return;
	}
	sc->sc_bhzdss0 = bh;

	if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LD_SS1,
	    PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
		aprint_error_dev(self, "can't map ld/ss1\n");
		return;
	}
	sc->sc_bhzdss1 = bh;

	if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CROSS,
	    PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
		aprint_error_dev(self, "can't map zx\n");
		return;
	}
	sc->sc_bhzx = bh;

	if (sbus_bus_map(bt, sa->sa_slot, sa->sa_offset + ZX_OFF_LX_CURSOR,
	    PAGE_SIZE, BUS_SPACE_MAP_LINEAR, &bh) != 0) {
		aprint_error_dev(self, "can't map zcu\n");
		return;
	}
	sc->sc_bhzcu = bh;

	fb->fb_driver = &zx_fbdriver;
	fb->fb_device = sc->sc_dv;
	fb->fb_flags = device_cfdata(sc->sc_dv)->cf_flags & FB_USERMASK;
	fb->fb_pfour = NULL;
	fb->fb_linebytes = prom_getpropint(sa->sa_node, "linebytes", 8192);

	width = prom_getpropint(sa->sa_node, "width", 1280);
	height = prom_getpropint(sa->sa_node, "height", 1024);
	fb_setsize_obp(fb, 32, width, height, sa->sa_node);

	fb->fb_type.fb_cmsize = 256;
	fb->fb_type.fb_depth = 32;
	fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
	fb->fb_type.fb_type = FBTYPE_SUNLEO;

	printf(": %d x %d", fb->fb_type.fb_width, fb->fb_type.fb_height);
	isconsole = fb_is_console(sa->sa_node);
	if (isconsole)
		printf(" (console)");
	printf("\n");

	if (sa->sa_nintr != 0)
		bus_intr_establish(bt, sa->sa_pri, IPL_NONE, zx_intr, sc);

	sc->sc_cmap = malloc(768, M_DEVBUF, M_NOWAIT);
	zx_reset(sc);

#if NWSDISPLAY > 0
	sc->sc_width = fb->fb_type.fb_width;
	sc->sc_stride = 8192; /* 32 bit */
	sc->sc_height = fb->fb_type.fb_height;

	/* setup rasops and so on for wsdisplay */
	wsfont_init();
	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
	sc->sc_bg = WS_DEFAULT_BG;

	vcons_init(&sc->vd, sc, &zx_defaultscreen, &zx_accessops);
	sc->vd.init_screen = zx_init_screen;

	if (isconsole) {
		/* we mess with zx_console_screen only once */
		vcons_init_screen(&sc->vd, &zx_console_screen, 1,
		    &defattr);
		zx_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
		
		zx_defaultscreen.textops = &ri->ri_ops;
		zx_defaultscreen.capabilities = WSSCREEN_WSCOLORS;
		zx_defaultscreen.nrows = ri->ri_rows;
		zx_defaultscreen.ncols = ri->ri_cols;
		zx_fillrect(sc, 0, 0, width, height,
		     ri->ri_devcmap[defattr >> 16], ZX_STD_ROP);
		wsdisplay_cnattach(&zx_defaultscreen, ri, 0, 0, defattr);
		vcons_replay_msgbuf(&zx_console_screen);
	} else {
		/* 
		 * we're not the console so we just clear the screen and don't 
		 * set up any sort of text display
		 */
		if (zx_defaultscreen.textops == NULL) {
Beispiel #24
0
void
cgthreeattach(struct cgthree_softc *sc, const char *name, int isconsole)
{
	int i;
	struct fbdevice *fb = &sc->sc_fb;
	struct wsemuldisplaydev_attach_args aa;
	struct rasops_info *ri = &cg3_console_screen.scr_ri;
	unsigned long defattr;
	volatile struct fbcontrol *fbc = sc->sc_fbc;
	volatile struct bt_regs *bt = &fbc->fbc_dac;

	fb->fb_driver = &cgthreefbdriver;
	fb->fb_type.fb_cmsize = 256;
	fb->fb_type.fb_size = fb->fb_type.fb_height * fb->fb_linebytes;
	printf(": %s, %d x %d", name,
		fb->fb_type.fb_width, fb->fb_type.fb_height);

	/* Transfer video magic to board, if it's not running */
	if ((fbc->fbc_ctrl & FBC_TIMING) == 0) {
		int sense = (fbc->fbc_status & FBS_MSENSE);
		/* Search table for video timings fitting this monitor */
		for (i = 0; i < sizeof(cg3_videoctrl)/sizeof(cg3_videoctrl[0]);
		     i++) {
			int j;
			if (sense != cg3_videoctrl[i].sense)
				continue;

			printf(" setting video ctrl");
			for (j = 0; j < 12; j++)
				fbc->fbc_vcontrol[j] =
					cg3_videoctrl[i].vctrl[j];
			fbc->fbc_ctrl |= FBC_TIMING;
			break;
		}
	}

	/* make sure we are not blanked */
	cgthree_set_video(sc, 1);
	BT_INIT(bt, 0);

	if (isconsole) {
		printf(" (console)\n");
	} else
		printf("\n");

	fb_attach(fb, isconsole);

	sc->sc_width = fb->fb_type.fb_width;
	sc->sc_stride = fb->fb_type.fb_width;
	sc->sc_height = fb->fb_type.fb_height;

	/* setup rasops and so on for wsdisplay */
	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;

	vcons_init(&sc->vd, sc, &cgthree_defaultscreen, &cgthree_accessops);
	sc->vd.init_screen = cgthree_init_screen;

	if(isconsole) {
		/* we mess with cg3_console_screen only once */
		vcons_init_screen(&sc->vd, &cg3_console_screen, 1,
		    &defattr);
		memset(sc->sc_fb.fb_pixels, (defattr >> 16) & 0xff,
		    sc->sc_stride * sc->sc_height);
		cg3_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;

		cgthree_defaultscreen.textops = &ri->ri_ops;
		cgthree_defaultscreen.capabilities = ri->ri_caps;
		cgthree_defaultscreen.nrows = ri->ri_rows;
		cgthree_defaultscreen.ncols = ri->ri_cols;
		sc->vd.active = &cg3_console_screen;
		wsdisplay_cnattach(&cgthree_defaultscreen, ri, 0, 0, defattr);
		vcons_replay_msgbuf(&cg3_console_screen);
	} else {
		/* 
		 * we're not the console so we just clear the screen and don't 
		 * set up any sort of text display
		 */
	}