NetBSD/sys/dev/wscons/wsdisplay_vconsvar.h
macallan 9c10440f53 Add copycols() and copyrows() methods which, instead of calling the underlying
driver methods, call the driver's putchar() method to redraw the affected
areas.
For unaccelerated framebuffers where reads are expensive and we can't spare
any memory for a shadow framebuffer. Enabled by setting VCONS_DONT_READ in
scr_flags
2010-08-18 16:46:51 +00:00

131 lines
4.7 KiB
C

/* $NetBSD: wsdisplay_vconsvar.h,v 1.11 2010/08/18 16:46:51 macallan Exp $ */
/*-
* Copyright (c) 2005, 2006 Michael Lorenz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _WSDISPLAY_VCONS_H_
#define _WSDISPLAY_VCONS_H_
#include "opt_wsdisplay_compat.h"
#include "opt_vcons.h"
struct vcons_data;
struct vcons_screen {
struct rasops_info scr_ri;
LIST_ENTRY(vcons_screen) next;
void *scr_cookie;
struct vcons_data *scr_vd;
struct vcons_data *scr_origvd;
const struct wsscreen_descr *scr_type;
uint16_t *scr_chars;
long *scr_attrs;
long scr_defattr;
/* static flags set by the driver */
uint32_t scr_flags;
#define VCONS_NO_REDRAW 1 /* don't readraw in switch_screen */
#define VCONS_SCREEN_IS_STATIC 2 /* don't free() this vcons_screen */
#define VCONS_SWITCH_NEEDS_POLLING 4 /* rasops can overlap so we need to
* poll the busy flag when switching
* - for drivers that use software
* drawing */
#define VCONS_DONT_DRAW 8 /* don't draw on this screen at all */
#define VCONS_DONT_READ 0x10 /* avoid framebuffer reads */
/* status flags used by vcons */
uint32_t scr_status;
#define VCONS_IS_VISIBLE 1 /* this screen is currently visible */
/* non zero when some rasops operation is in progress */
int scr_busy;
#ifdef WSDISPLAY_SCROLLSUPPORT
int scr_lines_in_buffer;
int scr_current_line;
int scr_line_wanted;
int scr_offset_to_zero;
int scr_current_offset;
#endif
};
#define SCREEN_IS_VISIBLE(scr) (((scr)->scr_status & VCONS_IS_VISIBLE) != 0)
#define SCREEN_IS_BUSY(scr) ((scr)->scr_busy != 0)
#define SCREEN_CAN_DRAW(scr) (((scr)->scr_flags & VCONS_DONT_DRAW) == 0)
#define SCREEN_BUSY(scr) ((scr)->scr_busy = 1)
#define SCREEN_IDLE(scr) ((scr)->scr_busy = 0)
#define SCREEN_VISIBLE(scr) ((scr)->scr_status |= VCONS_IS_VISIBLE)
#define SCREEN_INVISIBLE(scr) ((scr)->scr_status &= ~VCONS_IS_VISIBLE)
#define SCREEN_DISABLE_DRAWING(scr) ((scr)->scr_flags |= VCONS_DONT_DRAW)
#define SCREEN_ENABLE_DRAWING(scr) ((scr)->scr_flags &= ~VCONS_DONT_DRAW)
struct vcons_data {
/* usually the drivers softc */
void *cookie;
/*
* setup the rasops part of the passed vcons_screen, like
* geometry, framebuffer address, font, characters, acceleration.
* we pass the cookie as 1st parameter
*/
void (*init_screen)(void *, struct vcons_screen *, int,
long *);
/* accessops */
int (*ioctl)(void *, void *, u_long, void *, int, struct lwp *);
/* rasops */
void (*copycols)(void *, int, int, int, int);
void (*erasecols)(void *, int, int, int, long);
void (*copyrows)(void *, int, int, int);
void (*eraserows)(void *, int, int, long);
void (*putchar)(void *, int, int, u_int, long);
void (*cursor)(void *, int, int, int);
/* called before vcons_redraw_screen */
void (*show_screen_cb)(struct vcons_screen *);
/* virtual screen management stuff */
void (*switch_cb)(void *, int, int);
void *switch_cb_arg;
#ifdef VCONS_SWITCH_ASYNC
lwp_t *redraw_thread;
int start_drawing, done_drawing; /* for the drawing thread */
#endif
struct callout switch_callout;
uint32_t switch_pending;
LIST_HEAD(, vcons_screen) screens;
struct vcons_screen *active, *wanted;
const struct wsscreen_descr *currenttype;
int switch_poll_count;
};
int vcons_init(struct vcons_data *, void *cookie, struct wsscreen_descr *,
struct wsdisplay_accessops *);
int vcons_init_screen(struct vcons_data *, struct vcons_screen *, int,
long *);
void vcons_redraw_screen(struct vcons_screen *);
void vcons_replay_msgbuf(struct vcons_screen *);
#endif /* _WSDISPLAY_VCONS_H_ */