wsdisplay_vconsvar.h revision 1.3 1 /* $NetBSD: wsdisplay_vconsvar.h,v 1.3 2006/02/19 03:51:03 macallan Exp $ */
2
3 /*-
4 * Copyright (c) 2005, 2006 Michael Lorenz
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the NetBSD
18 * Foundation, Inc. and its contributors.
19 * 4. Neither the name of The NetBSD Foundation nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #ifndef _WSDISPLAY_VCONS_H_
37 #define _WSDISPLAY_VCONS_H_
38
39 struct vcons_data;
40
41 struct vcons_screen {
42 struct rasops_info scr_ri;
43 LIST_ENTRY(vcons_screen) next;
44 void *scr_cookie;
45 struct vcons_data *scr_vd;
46 struct vcons_data *scr_origvd;
47 const struct wsscreen_descr *scr_type;
48 uint16_t *scr_chars;
49 long *scr_attrs;
50 long scr_defattr;
51 /* static flags set by the driver */
52 uint32_t scr_flags;
53 #define VCONS_NO_REDRAW 1 /* don't readraw in switch_screen */
54 #define VCONS_SCREEN_IS_STATIC 2 /* don't free() this vcons_screen */
55 #define VCONS_SWITCH_NEEDS_POLLING 4 /* rasops can overlap so we need to
56 * poll the busy flag when switching
57 * - for drivers that use software
58 * drawing */
59 #define VCONS_DONT_DRAW 8 /* don't draw on this screen at all */
60 /* status flags used by vcons */
61 uint32_t scr_status;
62 #define VCONS_IS_VISIBLE 1 /* this screen is currently visible */
63 /* non zero when some rasops operation is in progress */
64 int scr_busy;
65 };
66
67 #define SCREEN_IS_VISIBLE(scr) (((scr)->scr_status & VCONS_IS_VISIBLE) != 0)
68 #define SCREEN_IS_BUSY(scr) ((scr)->scr_busy != 0)
69 #define SCREEN_CAN_DRAW(scr) (((scr)->scr_flags & VCONS_DONT_DRAW) == 0)
70 #define SCREEN_BUSY(scr) ((scr)->scr_busy = 1)
71 #define SCREEN_IDLE(scr) ((scr)->scr_busy = 0)
72 #define SCREEN_VISIBLE(scr) ((scr)->scr_status |= VCONS_IS_VISIBLE)
73 #define SCREEN_INVISIBLE(scr) ((scr)->scr_status &= ~VCONS_IS_VISIBLE)
74 #define SCREEN_DISABLE_DRAWING(scr) ((scr)->scr_flags |= VCONS_DONT_DRAW)
75 #define SCREEN_ENABLE_DRAWING(scr) ((scr)->scr_flags &= ~VCONS_DONT_DRAW)
76 struct vcons_data {
77 /* usually the drivers softc */
78 void *cookie;
79
80 /*
81 * setup the rasops part of the passed vcons_screen, like
82 * geometry, framebuffer address, font, characters, acceleration.
83 * we pass the cookie as 1st parameter
84 */
85 void (*init_screen)(void *, struct vcons_screen *, int,
86 long *);
87
88 /* rasops */
89 void (*copycols)(void *, int, int, int, int);
90 void (*erasecols)(void *, int, int, int, long);
91 void (*copyrows)(void *, int, int, int);
92 void (*eraserows)(void *, int, int, long);
93 void (*putchar)(void *, int, int, u_int, long);
94 void (*cursor)(void *, int, int, int);
95 /* called before cvons_redraw_screen */
96 void (*show_screen_cb)(struct vcons_screen *);
97 /* virtual screen management stuff */
98 void (*switch_cb)(void *, int, int);
99 void *switch_cb_arg;
100 struct callout switch_callout;
101 uint32_t switch_pending;
102 LIST_HEAD(, vcons_screen) screens;
103 struct vcons_screen *active, *wanted;
104 const struct wsscreen_descr *currenttype;
105 #ifdef DIAGNOSTIC
106 int switch_poll_count;
107 #endif
108 };
109
110 int vcons_init(struct vcons_data *, void *cookie, struct wsscreen_descr *,
111 struct wsdisplay_accessops *);
112
113 int vcons_init_screen(struct vcons_data *, struct vcons_screen *, int,
114 long *);
115
116 void vcons_redraw_screen(struct vcons_screen *);
117
118
119
120 #endif /* _WSDISPLAY_VCONS_H_ */
121