コード例 #1
0
static int
bcmfb_init(int unit, video_adapter_t *adp, int flags)
{
	struct video_adapter_softc *sc;
	video_info_t *vi;

	sc = (struct video_adapter_softc *)adp;
	vi = &adp->va_info;

	vid_init_struct(adp, "bcmfb", -1, unit);

	sc->font = dflt_font_16;
	vi->vi_cheight = BCMFB_FONT_HEIGHT;
	vi->vi_cwidth = 8;
	vi->vi_width = sc->width/8;
	vi->vi_height = sc->height/vi->vi_cheight;

	/*
	 * Clamp width/height to syscons maximums
	 */
	if (vi->vi_width > COL)
		vi->vi_width = COL;
	if (vi->vi_height > ROW)
		vi->vi_height = ROW;

	sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2;
	sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2;

	adp->va_window = (vm_offset_t) bcmfb_static_window;
	adp->va_flags |= V_ADP_FONT /* | V_ADP_COLOR | V_ADP_MODECHANGE */;

	vid_register(&sc->va);

	return (0);
}
コード例 #2
0
ファイル: terasic_mtl_syscons.c プロジェクト: 2asoft/freebsd
static int
terasic_mtl_vidsw_init(int unit, video_adapter_t *adp, int flags)
{
	struct terasic_mtl_softc *sc;
	video_info_t *vi;

	sc = (struct terasic_mtl_softc *)adp;

	vi = &adp->va_info;
	vid_init_struct(adp, "terasic_mtl_syscons", -1, unit);

	vi->vi_width = TERASIC_MTL_COLS;
	if (vi->vi_width > COL)
		vi->vi_width = COL;
	vi->vi_height = TERASIC_MTL_ROWS;
	if (vi->vi_height > ROW)
		vi->vi_height = ROW;

	/*
	 * XXXRW: It's not quite clear how these should be initialised.
	 */
	vi->vi_cwidth = 0;
	vi->vi_cheight = 0;
	vi->vi_flags = V_INFO_COLOR;
	vi->vi_mem_model = V_INFO_MM_OTHER;

	/*
	 * Software text frame buffer from which we update the actual MTL
	 * frame buffer when asked to.
	 */
	adp->va_window = (vm_offset_t)sc->mtl_text_soft;

	/*
	 * Declare video adapter capabilities -- at this point, simply color
	 * support, as MTL doesn't support screen borders, font loading, or
	 * mode changes.
	 *
	 * XXXRW: It's unclear if V_ADP_INITIALIZED is needed here; other
	 * syscons(4) drivers are inconsistent about this and
	 * V_ADP_REGISTERED.
	 */
	adp->va_flags |= V_ADP_COLOR | V_ADP_INITIALIZED;
	if (vid_register(adp) < 0) {
		device_printf(sc->mtl_dev, "%s: vid_register failed\n",
		    __func__);
		return (ENXIO);
	}
	adp->va_flags |= V_ADP_REGISTERED;
	return (0);
}
コード例 #3
0
ファイル: wii_fb.c プロジェクト: MattDooner/freebsd-west
static int
wiifb_init(int unit, video_adapter_t *adp, int flags)
{
	struct wiifb_softc *sc;
	video_info_t *vi;

	sc = (struct wiifb_softc *)adp;
	vi = &adp->va_info;

	vid_init_struct(adp, "wiifb", -1, unit);

	sc->sc_font = dflt_font_8;
	vi->vi_cheight = WIIFB_FONT_HEIGHT;
	vi->vi_width = sc->sc_width/8;
	vi->vi_height = sc->sc_height/vi->vi_cheight;
	vi->vi_cwidth = 8;

	/*
	 * Clamp width/height to syscons maximums
	 */
	if (vi->vi_width > COL)
		vi->vi_width = COL;
	if (vi->vi_height > ROW)
		vi->vi_height = ROW;

	sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
	sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight))/2;

	adp->va_window = (vm_offset_t) wiifb_static_window;
	/* XXX no colour support */
	adp->va_flags |= V_ADP_FONT | /*V_ADP_COLOR |*/ V_ADP_MODECHANGE;

	vid_register(&sc->sc_va);

	wiifb_configure_tv_mode(sc);
	wiifb_setup_framebuffer(sc);
	wiifb_enable_interrupts(sc);
	wiifb_clear(adp);

	return (0);
}
コード例 #4
0
static int
ofwfb_init(int unit, video_adapter_t *adp, int flags)
{
    struct ofwfb_softc *sc;
    video_info_t *vi;
    int cborder;
    int font_height;

    sc = (struct ofwfb_softc *)adp;
    vi = &adp->va_info;

    vid_init_struct(adp, "ofwfb", -1, unit);

    /* The default font size can be overridden by loader */
    font_height = 16;
    TUNABLE_INT_FETCH("hw.syscons.fsize", &font_height);
    if (font_height == 8) {
        sc->sc_font = dflt_font_8;
        sc->sc_font_height = 8;
    } else if (font_height == 14) {
        sc->sc_font = dflt_font_14;
        sc->sc_font_height = 14;
    } else {
        /* default is 8x16 */
        sc->sc_font = dflt_font_16;
        sc->sc_font_height = 16;
    }

    /* The user can set a border in chars - default is 1 char width */
    cborder = 1;
    TUNABLE_INT_FETCH("hw.syscons.border", &cborder);

    vi->vi_cheight = sc->sc_font_height;
    vi->vi_width = sc->sc_width/8 - 2*cborder;
    vi->vi_height = sc->sc_height/sc->sc_font_height - 2*cborder;
    vi->vi_cwidth = 8;

    /*
     * Clamp width/height to syscons maximums
     */
    if (vi->vi_width > COL)
        vi->vi_width = COL;
    if (vi->vi_height > ROW)
        vi->vi_height = ROW;

    sc->sc_xmargin = (sc->sc_width - (vi->vi_width * vi->vi_cwidth)) / 2;
    sc->sc_ymargin = (sc->sc_height - (vi->vi_height * vi->vi_cheight))/2;

    /*
     * Avoid huge amounts of conditional code in syscons by
     * defining a dummy h/w text display buffer.
     */
    adp->va_window = (vm_offset_t) ofwfb_static_window;

    /*
     * Enable future font-loading and flag color support, as well as
     * adding V_ADP_MODECHANGE so that we ofwfb_set_mode() gets called
     * when the X server shuts down. This enables us to get the console
     * back when X disappears.
     */
    adp->va_flags |= V_ADP_FONT | V_ADP_COLOR | V_ADP_MODECHANGE;

    ofwfb_set_mode(&sc->sc_va, 0);

    vid_register(&sc->sc_va);

    return (0);
}
コード例 #5
0
ファイル: gfb_pci.c プロジェクト: UnitedMarsupials/kame
int
pcigfb_attach(device_t dev)
{
	int s;
	gfb_softc_t sc;
	video_adapter_t *adp;
	int unit, flags, error, rid, va_index;
#ifdef __alpha__
	struct ctb *ctb;
#endif /* __alpha__ */

	s = splimp();
	error = 0;
	unit = device_get_unit(dev);
	flags = device_get_flags(dev);
	sc = device_get_softc(dev);
	sc->rev = pci_get_revid(dev);
	rid = GFB_MEM_BASE_RID;
	sc->res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 1,
	    RF_ACTIVE|PCI_RF_DENSE);
	if(sc->res == NULL) {
		device_printf(dev, "couldn't map memory\n");
		goto fail;
	}
	sc->btag = rman_get_bustag(sc->res);
	sc->bhandle = rman_get_bushandle(sc->res);

	/* Allocate interrupt (irq)... */
	rid = 0x0;
	sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
	    RF_SHAREABLE|RF_ACTIVE);
	if(sc->irq == NULL) {
		device_printf(dev, "Couldn't map interrupt\n");
		goto fail;
	}
	if((va_index = vid_find_adapter(sc->driver_name, unit)) < 0) {
		sc->adp = (video_adapter_t *)malloc(sizeof(video_adapter_t),
		    M_DEVBUF, M_NOWAIT);
		adp = sc->adp;
		bzero(adp, sizeof(video_adapter_t));
		vid_init_struct(adp, sc->driver_name, sc->type, unit);
		if(vid_register(adp) < 0) {
			free(sc->adp, M_DEVBUF);
			goto fail;
		}
		adp->va_flags |= V_ADP_REGISTERED;
		adp->va_model = sc->model;
		adp->va_mem_base = (vm_offset_t)rman_get_virtual(sc->res);
		adp->va_mem_size = rman_get_end(sc->res) -
		    rman_get_start(sc->res);
		adp->va_io_base = NULL;
		adp->va_io_size = 0;
		adp->va_crtc_addr = NULL;
		gfb_device_softcs[sc->model][unit] = sc;
		sc->gfbc = (struct gfb_conf *)malloc(sizeof(struct gfb_conf),
		    M_DEVBUF, M_NOWAIT);
		bzero(sc->gfbc, sizeof(struct gfb_conf));
		if((*vidsw[adp->va_index]->init)(unit, adp, flags)) {
			device_printf(dev, "Couldn't initialize adapter\n");
			vid_unregister(adp);
			gfb_device_softcs[sc->model][unit] = NULL;
			free(sc->gfbc, M_DEVBUF);
			free(sc->adp, M_DEVBUF);
			goto fail;
		}
		sc->gfbc->palette.red =
		    (u_char *)malloc(sc->gfbc->palette.count, M_DEVBUF,
		    M_NOWAIT);
		sc->gfbc->palette.green =
		    (u_char *)malloc(sc->gfbc->palette.count, M_DEVBUF,
		    M_NOWAIT);
		sc->gfbc->palette.blue =
		    (u_char *)malloc(sc->gfbc->palette.count, M_DEVBUF,
		    M_NOWAIT);
		sc->gfbc->cursor_palette.red =
		    (u_char *)malloc(sc->gfbc->cursor_palette.count, M_DEVBUF,
		    M_NOWAIT);
		sc->gfbc->cursor_palette.green =
		    (u_char *)malloc(sc->gfbc->cursor_palette.count, M_DEVBUF,
		    M_NOWAIT);
		sc->gfbc->cursor_palette.blue =
		    (u_char *)malloc(sc->gfbc->cursor_palette.count, M_DEVBUF,
		    M_NOWAIT);
		if(gfb_init(unit, adp, flags)) {
			device_printf(dev, "Couldn't initialize framebuffer\n");
			vid_unregister(adp);
			gfb_device_softcs[sc->model][unit] = NULL;
			free(sc->gfbc->cursor_palette.blue, M_DEVBUF);
			free(sc->gfbc->cursor_palette.green, M_DEVBUF);
			free(sc->gfbc->cursor_palette.red, M_DEVBUF);
			free(sc->gfbc->palette.blue, M_DEVBUF);
			free(sc->gfbc->palette.green, M_DEVBUF);
			free(sc->gfbc->palette.red, M_DEVBUF);
			free(sc->gfbc, M_DEVBUF);
			free(sc->adp, M_DEVBUF);
			goto fail;
		}
	} else {
		(*vidsw[va_index]->probe)(unit, &adp, (void *)sc->driver_name,
		    flags);
		sc->adp = adp;
		sc->gfbc = gfb_device_softcs[sc->model][unit]->gfbc;
		gfb_device_softcs[sc->model][unit] = sc;
	}

	/*
	   This is a back-door for PCI devices--since FreeBSD no longer supports
	   PCI configuration-space accesses during the *configure() phase for
	   video adapters, we cannot identify a PCI device as the console during
	   the first call to sccnattach(). There must be a second chance for PCI
	   adapters to be recognized as the console, and this is it...
	*/
#ifdef __alpha__
	ctb = (struct ctb *)(((caddr_t)hwrpb) + hwrpb->rpb_ctb_off);
	if (ctb->ctb_term_type == 3) /* Display adapter */
		sccnattach();
#endif /* __alpha__ */

	device_printf(dev, "Board type %s\n", sc->gfbc->name);
	device_printf(dev, "%d x %d, %dbpp, %s RAMDAC\n",
	       sc->adp->va_info.vi_width, sc->adp->va_info.vi_height,
	       sc->adp->va_info.vi_depth, sc->gfbc->ramdac_name);
#ifdef FB_INSTALL_CDEV
	/* attach a virtual frame buffer device */
	error = fb_attach(makedev(0, unit), sc->adp, sc->cdevsw);
	if(error)
		goto fail;
	if(bootverbose)
		(*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose);
#if experimental
	device_add_child(dev, "fb", -1);
	bus_generic_attach(dev);
#endif /*experimental*/
#endif /*FB_INSTALL_CDEV*/
	goto done;
fail:
	if(sc->intrhand != NULL) {
		bus_teardown_intr(dev, sc->irq, sc->intrhand);
		sc->intrhand = NULL;
	}
	if(sc->irq != NULL) {
		rid = 0x0;
		bus_release_resource(dev, SYS_RES_IRQ, rid, sc->irq);
		sc->irq = NULL;
	}
	if(sc->res != NULL) {
		rid = GFB_MEM_BASE_RID;
		bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->res);
		sc->res = NULL;
	}
	error = ENXIO;
done:
	splx(s);
	return(error);
}