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