Example #1
0
static int
fade_saver(video_adapter_t *adp, int blank)
{
	static int count = 0;
	u_char pal[256*3];
	int i;

	if (blank) {
		if (ISPALAVAIL(adp->va_flags)) {
			if (count <= 0)
				vidd_save_palette(adp, palette);
			if (count < 256) {
				pal[0] = pal[1] = pal[2] = 0;
				for (i = 3; i < 256*3; i++) {
					if (palette[i] - count > 60)
						pal[i] = palette[i] - count;
					else
						pal[i] = 60;
				}
				vidd_load_palette(adp, pal);
				count++;
			}
		} else {
	    		vidd_blank_display(adp, V_DISPLAY_BLANK);
		}
	} else {
		if (ISPALAVAIL(adp->va_flags)) {
			vidd_load_palette(adp, palette);
			count = 0;
		} else {
	    		vidd_blank_display(adp, V_DISPLAY_ON);
		}
	}
	return 0;
}
Example #2
0
static int
warp_saver(video_adapter_t *adp, int blank)
{
	int pl;
	
	if (blank) {
		/* switch to graphics mode */
		if (blanked <= 0) {
			pl = splhigh();
			vidd_set_mode(adp, scrmode);
			vidd_load_palette(adp, warp_pal);
			vidd_set_border(adp, 0);
			blanked++;
			vid = (u_char *)adp->va_window;
			banksize = adp->va_window_size;
			bpsl = adp->va_line_width;
			splx(pl);
			vidd_clear(adp);
		}
		/* update display */
		warp_update(adp);
	} else {
		blanked = 0;
	}
	return (0);
}
Example #3
0
static int
rain_saver(video_adapter_t *adp, int blank)
{
	int i, j, o, p, pl;
	u_char temp;
	int last_origin = -1;

	if (blank) {
		/* switch to graphics mode */
		if (blanked <= 0) {
			pl = splhigh();
			vidd_set_mode(adp, scrmode);
			vidd_load_palette(adp, rain_pal);
			vidd_set_border(adp, 0);
			blanked++;
			vid = (u_char *)adp->va_window;
			banksize = adp->va_window_size;
			bpsl = adp->va_line_width;
			splx(pl);
			for (i = 0; i < bpsl*scrh; i += banksize) {
				SET_ORIGIN(adp, i);
				if ((bpsl * scrh - i) < banksize)
					bzero(vid, bpsl * scrh - i);
				else
					bzero(vid, banksize);
			}
			SET_ORIGIN(adp, 0);
			for (i = 0, o = 0, p = 0; i < scrw; i += 2, p += 2) {
				if (p > banksize) {
					p -= banksize;
					o += banksize;
					SET_ORIGIN(adp, o);
				}
				vid[p] = 1 + (random() % MAX);
			}
			o = 0; p = 0;
			for (j = 1; j < scrh; j++)
			  for (i = 0, p = bpsl * (j - 1) - o; i < scrw; i += 2, p+= 2) {
			  	while (p > banksize) {
					p -= banksize;
					o += banksize;
				}
				SET_ORIGIN(adp, o);
				temp = (vid[p] < MAX) ? 1 + vid[p] : 1;
				if (p + bpsl < banksize) {
					vid[p + bpsl] = temp;
				} else {
					SET_ORIGIN(adp, o + banksize);
					vid[p + bpsl - banksize] = temp;
				}
			  }
		}
		
		/* update display */
		rain_update(adp);
	} else {
		blanked = 0;
	}
	return (0);
}
static int
bmp_splash(video_adapter_t *adp, int on)
{
    static u_char	pal[256*3];
    static long		time_stamp;
    u_char		tpal[256*3];
    static int		fading = TRUE, brightness = FADE_LEVELS;
    struct timeval	tv;
    int			i;

    if (on) {
	if (!splash_on) {
	    /* set up the video mode and draw something */
	    if (vidd_set_mode(adp, splash_mode))
		return 1;
	    if (bmp_Draw(adp))
		return 1;
	    vidd_save_palette(adp, pal);
	    time_stamp = 0;
	    splash_on = TRUE;
	}
	/*
	 * This is a kludge to fade the image away.  This section of the 
	 * code takes effect only after the system is completely up.
	 * FADE_TIMEOUT should be configurable.
	 */
	if (!cold) {
	    getmicrotime(&tv);
	    if (time_stamp == 0)
		time_stamp = tv.tv_sec;
	    if (tv.tv_sec > time_stamp + FADE_TIMEOUT) {
		if (fading)
		    if (brightness == 0) {
			fading = FALSE;
			brightness++;
		    }
		    else brightness--;
		else
		    if (brightness == FADE_LEVELS) {
			fading = TRUE;
			brightness--;
		    }
		    else brightness++;
		for (i = 0; i < sizeof(pal); ++i) {
		    tpal[i] = pal[i] * brightness / FADE_LEVELS;
		}
		vidd_load_palette(adp, tpal);
		time_stamp = tv.tv_sec;
	    }
	}
	return 0;
    } else {
	/* the video mode will be restored by the caller */
	splash_on = FALSE;
	return 0;
    }
}
Example #5
0
static void
rain_update(video_adapter_t *adp)
{
	int i, t;

	t = rain_pal[BLUE(MAX)];
	for (i = MAX; i > 1; i--)
		rain_pal[BLUE(i)] = rain_pal[BLUE(i - 1)];
	rain_pal[BLUE(1)] = t;
	vidd_load_palette(adp, rain_pal);
}
Example #6
0
static void
vga_resume(device_t dev)
{
	vga_softc_t *sc;

	sc = device_get_softc(dev);

	if (sc->state_buf != NULL) {
		if (vidd_load_state(sc->adp, sc->state_buf) != 0)
			device_printf(dev, "failed to reload state\n");
		free(sc->state_buf, M_TEMP);
		sc->state_buf = NULL;
	}
	if (sc->pal_buf != NULL) {
		if (vidd_load_palette(sc->adp, sc->pal_buf) != 0)
			device_printf(dev, "failed to reload palette\n");
		free(sc->pal_buf, M_TEMP);
		sc->pal_buf = NULL;
	}
}
Example #7
0
static int
pcx_draw(video_adapter_t *adp)
{
	uint8_t *vidmem;
	int swidth, sheight, sbpsl, sdepth, splanes;
	int banksize, origin;
	int c, i, j, pos, scan, x, y;
	uint8_t line[MAXSCANLINE];

	if (pcx_info.zlen < 1)
		return (1);

	vidd_load_palette(adp, pcx_info.palette);

	vidmem = (uint8_t *)adp->va_window;
	swidth = adp->va_info.vi_width;
	sheight = adp->va_info.vi_height;
	sbpsl = adp->va_line_width;
	sdepth = adp->va_info.vi_depth;
	splanes = adp->va_info.vi_planes;
	banksize = adp->va_window_size;

	for (origin = 0; origin < sheight*sbpsl; origin += banksize) {
		vidd_set_win_org(adp, origin);
		bzero(vidmem, banksize);
	}

	x = (swidth - pcx_info.width) / 2;
	y = (sheight - pcx_info.height) / 2;
	origin = 0;
	pos = y * sbpsl + x;
	while (pos > banksize) {
		pos -= banksize;
		origin += banksize;
	}
	vidd_set_win_org(adp, origin);

	for (scan = i = 0; scan < pcx_info.height; ++scan, ++y, pos += sbpsl) {
		for (j = 0; j < pcx_info.bpsl && i < pcx_info.zlen; ++i) {
			if ((pcx_info.zdata[i] & 0xc0) == 0xc0) {
				c = pcx_info.zdata[i++] & 0x3f;
				if (i >= pcx_info.zlen)
					return (1);
			} else {
				c = 1;
			}
			if (j + c > pcx_info.bpsl)
				return (1);
			while (c--)
				line[j++] = pcx_info.zdata[i];
		}

		if (pos > banksize) {
			origin += banksize;
			pos -= banksize;
			vidd_set_win_org(adp, origin);
		}

		if (pos + pcx_info.width > banksize) {
			/* scanline crosses bank boundary */
			j = banksize - pos;
			bcopy(line, vidmem + pos, j);
			origin += banksize;
			pos -= banksize;
			vidd_set_win_org(adp, origin);
			bcopy(line + j, vidmem, pcx_info.width - j);
		} else {
			bcopy(line, vidmem + pos, pcx_info.width);
		}
	}

	return (0);
}
int
sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
{
    scr_stat *scp;
    video_adapter_t *adp;
    video_info_t info;
    video_adapter_info_t adp_info;
    int error;
    int s;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    int ival;
#endif

    scp = SC_STAT(tp);
    if (scp == NULL)		/* tp == SC_MOUSE */
        return ENOIOCTL;
    adp = scp->sc->adp;
    if (adp == NULL)		/* shouldn't happen??? */
        return ENODEV;

    switch (cmd) {

    case CONS_CURRENTADP:	/* get current adapter index */
    case FBIO_ADAPTER:
        return fb_ioctl(adp, FBIO_ADAPTER, data);

    case CONS_CURRENT:  	/* get current adapter type */
    case FBIO_ADPTYPE:
        return fb_ioctl(adp, FBIO_ADPTYPE, data);

    case OLD_CONS_ADPINFO:	/* adapter information (old interface) */
        if (((old_video_adapter_t *)data)->va_index >= 0) {
            adp = vid_get_adapter(((old_video_adapter_t *)data)->va_index);
            if (adp == NULL)
                return ENODEV;
        }
        ((old_video_adapter_t *)data)->va_index = adp->va_index;
        ((old_video_adapter_t *)data)->va_type = adp->va_type;
        ((old_video_adapter_t *)data)->va_flags = adp->va_flags;
        ((old_video_adapter_t *)data)->va_crtc_addr = adp->va_crtc_addr;
        ((old_video_adapter_t *)data)->va_window = adp->va_window;
        ((old_video_adapter_t *)data)->va_window_size = adp->va_window_size;
        ((old_video_adapter_t *)data)->va_window_gran = adp->va_window_gran;
        ((old_video_adapter_t *)data)->va_buffer = adp->va_buffer;
        ((old_video_adapter_t *)data)->va_buffer_size = adp->va_buffer_size;
        ((old_video_adapter_t *)data)->va_mode = adp->va_mode;
        ((old_video_adapter_t *)data)->va_initial_mode = adp->va_initial_mode;
        ((old_video_adapter_t *)data)->va_initial_bios_mode
            = adp->va_initial_bios_mode;
        return 0;

    case OLD_CONS_ADPINFO2:	/* adapter information (yet another old I/F) */
        adp_info.va_index = ((old_video_adapter_info_t *)data)->va_index;
        if (adp_info.va_index >= 0) {
            adp = vid_get_adapter(adp_info.va_index);
            if (adp == NULL)
                return ENODEV;
        }
        error = fb_ioctl(adp, FBIO_ADPINFO, &adp_info);
        if (error == 0)
            bcopy(&adp_info, data, sizeof(old_video_adapter_info_t));
        return error;

    case CONS_ADPINFO:		/* adapter information */
    case FBIO_ADPINFO:
        if (((video_adapter_info_t *)data)->va_index >= 0) {
            adp = vid_get_adapter(((video_adapter_info_t *)data)->va_index);
            if (adp == NULL)
                return ENODEV;
        }
        return fb_ioctl(adp, FBIO_ADPINFO, data);

    case CONS_GET:      	/* get current video mode */
    case FBIO_GETMODE:
        *(int *)data = scp->mode;
        return 0;

#ifndef SC_NO_MODE_CHANGE
    case FBIO_SETMODE:		/* set video mode */
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        info.vi_mode = *(int *)data;
        error = fb_ioctl(adp, FBIO_MODEINFO, &info);
        if (error)
            return error;
        if (info.vi_flags & V_INFO_GRAPHICS)
            return sc_set_graphics_mode(scp, tp, *(int *)data);
        else
            return sc_set_text_mode(scp, tp, *(int *)data, 0, 0, 0, 0);
#endif /* SC_NO_MODE_CHANGE */

    case OLD_CONS_MODEINFO:	/* get mode information (old infterface) */
        info.vi_mode = ((old_video_info_t *)data)->vi_mode;
        error = fb_ioctl(adp, FBIO_MODEINFO, &info);
        if (error == 0)
            bcopy(&info, (old_video_info_t *)data, sizeof(old_video_info_t));
        return error;

    case CONS_MODEINFO:		/* get mode information */
    case FBIO_MODEINFO:
        return fb_ioctl(adp, FBIO_MODEINFO, data);

    case OLD_CONS_FINDMODE:	/* find a matching video mode (old interface) */
        bzero(&info, sizeof(info));
        bcopy((old_video_info_t *)data, &info, sizeof(old_video_info_t));
        error = fb_ioctl(adp, FBIO_FINDMODE, &info);
        if (error == 0)
            bcopy(&info, (old_video_info_t *)data, sizeof(old_video_info_t));
        return error;

    case CONS_FINDMODE:		/* find a matching video mode */
    case FBIO_FINDMODE:
        return fb_ioctl(adp, FBIO_FINDMODE, data);

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    case _IO('c', 104):
        ival = IOCPARM_IVAL(data);
        data = (caddr_t)&ival;
        /* FALLTHROUGH */
#endif
    case CONS_SETWINORG:	/* set frame buffer window origin */
    case FBIO_SETWINORG:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, FBIO_SETWINORG, data);

    case FBIO_GETWINORG:	/* get frame buffer window origin */
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, FBIO_GETWINORG, data);

    case FBIO_GETDISPSTART:
    case FBIO_SETDISPSTART:
    case FBIO_GETLINEWIDTH:
    case FBIO_SETLINEWIDTH:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

    case FBIO_GETPALETTE:
    case FBIO_SETPALETTE:
    case FBIOPUTCMAP:
    case FBIOGETCMAP:
    case FBIOGTYPE:
    case FBIOGATTR:
    case FBIOSVIDEO:
    case FBIOGVIDEO:
    case FBIOSCURSOR:
    case FBIOGCURSOR:
    case FBIOSCURPOS:
    case FBIOGCURPOS:
    case FBIOGCURMAX:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

    case FBIO_BLANK:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

#ifndef SC_NO_MODE_CHANGE
    /* generic text modes */
    case SW_TEXT_80x25:
    case SW_TEXT_80x30:
    case SW_TEXT_80x43:
    case SW_TEXT_80x50:
    case SW_TEXT_80x60:
    /* FALLTHROUGH */

    /* VGA TEXT MODES */
    case SW_VGA_C40x25:
    case SW_VGA_C80x25:
    case SW_VGA_M80x25:
    case SW_VGA_C80x30:
    case SW_VGA_M80x30:
    case SW_VGA_C80x50:
    case SW_VGA_M80x50:
    case SW_VGA_C80x60:
    case SW_VGA_M80x60:
    case SW_VGA_C90x25:
    case SW_VGA_M90x25:
    case SW_VGA_C90x30:
    case SW_VGA_M90x30:
    case SW_VGA_C90x43:
    case SW_VGA_M90x43:
    case SW_VGA_C90x50:
    case SW_VGA_M90x50:
    case SW_VGA_C90x60:
    case SW_VGA_M90x60:
    case SW_B40x25:
    case SW_C40x25:
    case SW_B80x25:
    case SW_C80x25:
    case SW_ENH_B40x25:
    case SW_ENH_C40x25:
    case SW_ENH_B80x25:
    case SW_ENH_C80x25:
    case SW_ENH_B80x43:
    case SW_ENH_C80x43:
    case SW_EGAMONO80x25:

#ifdef PC98
    /* PC98 TEXT MODES */
    case SW_PC98_80x25:
    case SW_PC98_80x30:
#endif
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0, 0);

    /* GRAPHICS MODES */
    case SW_BG320:
    case SW_BG640:
    case SW_CG320:
    case SW_CG320_D:
    case SW_CG640_E:
    case SW_CG640x350:
    case SW_ENH_CG640:
    case SW_BG640x480:
    case SW_CG640x480:
    case SW_VGA_CG320:
    case SW_VGA_MODEX:
#ifdef PC98
    /* PC98 GRAPHICS MODES */
    case SW_PC98_EGC640x400:
    case SW_PC98_PEGC640x400:
    case SW_PC98_PEGC640x480:
#endif
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        return sc_set_graphics_mode(scp, tp, cmd & 0xff);
#endif /* SC_NO_MODE_CHANGE */

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    case _IO('K', 10):
        ival = IOCPARM_IVAL(data);
        data = (caddr_t)&ival;
        /* FALLTHROUGH */
#endif
    case KDSETMODE:     	/* set current mode of this (virtual) console */
        switch (*(int *)data) {
        case KD_TEXT:   	/* switch to TEXT (known) mode */
            /*
             * If scp->mode is of graphics modes, we don't know which
             * text mode to switch back to...
             */
            if (scp->status & GRAPHICS_MODE)
                return EINVAL;
            /* restore fonts & palette ! */
#if 0
#ifndef SC_NO_FONT_LOADING
            if (ISFONTAVAIL(adp->va_flags)
                    && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
                /*
                 * FONT KLUDGE
                 * Don't load fonts for now... XXX
                 */
                if (scp->sc->fonts_loaded & FONT_8)
                    sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
            if (scp->sc->fonts_loaded & FONT_14)
                sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
            if (scp->sc->fonts_loaded & FONT_16)
                sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
        }
#endif /* SC_NO_FONT_LOADING */
#endif

#ifndef SC_NO_PALETTE_LOADING
        vidd_load_palette(adp, scp->sc->palette);
#endif

#ifndef PC98
        /* move hardware cursor out of the way */
        vidd_set_hw_cursor(adp, -1, -1);
#endif

    /* FALLTHROUGH */

    case KD_TEXT1:  	/* switch to TEXT (known) mode */
        /*
         * If scp->mode is of graphics modes, we don't know which
         * text/pixel mode to switch back to...
         */
        if (scp->status & GRAPHICS_MODE)
            return EINVAL;
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
#ifndef PC98
        scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
        splx(s);
        /* no restore fonts & palette */
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
        sc_clear_screen(scp);
        scp->status &= ~UNKNOWN_MODE;
#else /* PC98 */
        scp->status &= ~UNKNOWN_MODE;
        /* no restore fonts & palette */
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
        sc_clear_screen(scp);
        splx(s);
#endif /* PC98 */
        return 0;

#ifdef SC_PIXEL_MODE
    case KD_PIXEL:		/* pixel (raster) display */
        if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
            return EINVAL;
        if (scp->status & GRAPHICS_MODE)
            return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
                                     scp->font_size, scp->font_width);
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
        scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
        splx(s);
        if (scp == scp->sc->cur_scp) {
            set_mode(scp);
#ifndef SC_NO_PALETTE_LOADING
            vidd_load_palette(adp, scp->sc->palette);
#endif
        }
        sc_clear_screen(scp);
        scp->status &= ~UNKNOWN_MODE;
        return 0;
#endif /* SC_PIXEL_MODE */

    case KD_GRAPHICS:	/* switch to GRAPHICS (unknown) mode */
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
        scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
        splx(s);
#ifdef PC98
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
#endif
        return 0;

    default:
        return EINVAL;
    }
    /* NOT REACHED */

#ifdef SC_PIXEL_MODE
case KDRASTER:		/* set pixel (raster) display mode */
    if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
        return ENODEV;
    return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
                             ((int *)data)[2], 8);
#endif /* SC_PIXEL_MODE */

case KDGETMODE:     	/* get current mode of this (virtual) console */
    /*
     * From the user program's point of view, KD_PIXEL is the same
     * as KD_TEXT...
     */
    *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
    return 0;

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 13):
    ival = IOCPARM_IVAL(data);
    data = (caddr_t)&ival;
    /* FALLTHROUGH */
#endif
case KDSBORDER:     	/* set border color of this (virtual) console */
    scp->border = *(int *)data;
    if (scp == scp->sc->cur_scp)
        sc_set_border(scp, scp->border);
    return 0;
}