Home | History | Annotate | Line # | Download | only in wscons
wsdisplay_vconsvar.h revision 1.27.12.1
      1  1.27.12.1   thorpej /*	$NetBSD: wsdisplay_vconsvar.h,v 1.27.12.1 2021/04/03 22:28:51 thorpej 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  *
     16        1.1  macallan  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17        1.1  macallan  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18        1.1  macallan  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19        1.1  macallan  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20        1.1  macallan  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21        1.1  macallan  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22        1.1  macallan  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23        1.1  macallan  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24        1.1  macallan  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25        1.1  macallan  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26        1.1  macallan  * POSSIBILITY OF SUCH DAMAGE.
     27        1.1  macallan  */
     28        1.1  macallan 
     29        1.1  macallan #ifndef _WSDISPLAY_VCONS_H_
     30        1.1  macallan #define _WSDISPLAY_VCONS_H_
     31        1.1  macallan 
     32       1.23  riastrad #ifdef _KERNEL_OPT
     33        1.8  macallan #include "opt_wsdisplay_compat.h"
     34        1.8  macallan #include "opt_vcons.h"
     35       1.23  riastrad #endif
     36        1.8  macallan 
     37  1.27.12.1   thorpej #include <sys/atomic.h>
     38  1.27.12.1   thorpej 
     39        1.1  macallan struct vcons_data;
     40        1.1  macallan 
     41        1.1  macallan struct vcons_screen {
     42        1.1  macallan 	struct rasops_info scr_ri;
     43        1.1  macallan 	LIST_ENTRY(vcons_screen) next;
     44        1.1  macallan 	void *scr_cookie;
     45        1.1  macallan 	struct vcons_data *scr_vd;
     46        1.2  jmcneill 	struct vcons_data *scr_origvd;
     47       1.25  macallan 	struct wsscreen_descr *scr_type;
     48       1.21  macallan 	uint32_t *scr_chars;
     49        1.1  macallan 	long *scr_attrs;
     50       1.25  macallan 	void (*putchar)(void *, int, int, u_int, long);
     51        1.1  macallan 	long scr_defattr;
     52        1.1  macallan 	/* static flags set by the driver */
     53        1.1  macallan 	uint32_t scr_flags;
     54        1.1  macallan #define VCONS_NO_REDRAW		1	/* don't readraw in switch_screen */
     55        1.1  macallan #define	VCONS_SCREEN_IS_STATIC	2	/* don't free() this vcons_screen */
     56        1.1  macallan #define VCONS_SWITCH_NEEDS_POLLING 4	/* rasops can overlap so we need to
     57        1.1  macallan 					 * poll the busy flag when switching
     58        1.1  macallan 					 * - for drivers that use software
     59        1.1  macallan 					 * drawing */
     60        1.3  macallan #define VCONS_DONT_DRAW		8	/* don't draw on this screen at all */
     61       1.12  macallan /*
     62       1.27   msaitoh  * the following flags are for drivers which either can't accelerate (all) copy
     63       1.12  macallan  * operations or where drawing characters is faster than the blitter
     64       1.12  macallan  * for example, Sun's Creator boards can't accelerate copycols()
     65       1.12  macallan  */
     66       1.12  macallan #define VCONS_NO_COPYCOLS	0x10	/* use putchar() based copycols() */
     67       1.22  macallan #define VCONS_NO_COPYROWS	0x20	/* use putchar() based copyrows() */
     68  1.27.12.1   thorpej #define VCONS_DONT_READ		(VCONS_NO_COPYCOLS|VCONS_NO_COPYROWS|VCONS_NO_CURSOR)
     69  1.27.12.1   thorpej 					/* avoid framebuffer reads */
     70       1.25  macallan #define VCONS_LOADFONT		0x40	/* driver can load_font() */
     71  1.27.12.1   thorpej #define VCONS_NO_CURSOR		0x80	/* use putchar() based cursor(), to
     72  1.27.12.1   thorpej 					 * avoid fb reads */
     73        1.1  macallan 	/* status flags used by vcons */
     74        1.1  macallan 	uint32_t scr_status;
     75        1.1  macallan #define VCONS_IS_VISIBLE	1	/* this screen is currently visible */
     76        1.1  macallan 	/* non zero when some rasops operation is in progress */
     77        1.1  macallan 	int scr_busy;
     78        1.8  macallan #ifdef WSDISPLAY_SCROLLSUPPORT
     79        1.8  macallan 	int scr_lines_in_buffer;
     80        1.8  macallan 	int scr_current_line;
     81        1.8  macallan 	int scr_line_wanted;
     82        1.8  macallan 	int scr_offset_to_zero;
     83        1.8  macallan 	int scr_current_offset;
     84        1.8  macallan #endif
     85       1.14  jmcneill #ifdef VCONS_DRAW_INTR
     86       1.16  jmcneill 	unsigned int scr_dirty;
     87       1.14  jmcneill #endif
     88        1.1  macallan };
     89        1.1  macallan 
     90        1.1  macallan #define SCREEN_IS_VISIBLE(scr) (((scr)->scr_status & VCONS_IS_VISIBLE) != 0)
     91  1.27.12.1   thorpej #define SCREEN_IS_BUSY(scr) (membar_consumer(), (scr)->scr_busy != 0)
     92        1.3  macallan #define SCREEN_CAN_DRAW(scr) (((scr)->scr_flags & VCONS_DONT_DRAW) == 0)
     93  1.27.12.1   thorpej #define SCREEN_BUSY(scr) ((scr)->scr_busy = 1, membar_producer())
     94  1.27.12.1   thorpej #define SCREEN_IDLE(scr) ((scr)->scr_busy = 0, membar_producer())
     95        1.1  macallan #define SCREEN_VISIBLE(scr) ((scr)->scr_status |= VCONS_IS_VISIBLE)
     96        1.1  macallan #define SCREEN_INVISIBLE(scr) ((scr)->scr_status &= ~VCONS_IS_VISIBLE)
     97        1.3  macallan #define SCREEN_DISABLE_DRAWING(scr) ((scr)->scr_flags |= VCONS_DONT_DRAW)
     98        1.3  macallan #define SCREEN_ENABLE_DRAWING(scr) ((scr)->scr_flags &= ~VCONS_DONT_DRAW)
     99        1.8  macallan 
    100       1.24  macallan #define DEFATTR ((WS_DEFAULT_FG << 24) || (WS_DEFAULT_BG << 16))
    101       1.24  macallan 
    102        1.1  macallan struct vcons_data {
    103        1.1  macallan 	/* usually the drivers softc */
    104        1.1  macallan 	void *cookie;
    105       1.27   msaitoh 
    106        1.1  macallan 	/*
    107        1.1  macallan 	 * setup the rasops part of the passed vcons_screen, like
    108        1.1  macallan 	 * geometry, framebuffer address, font, characters, acceleration.
    109        1.1  macallan 	 * we pass the cookie as 1st parameter
    110        1.1  macallan 	 */
    111       1.27   msaitoh 	void (*init_screen)(void *, struct vcons_screen *, int,
    112        1.1  macallan 	    long *);
    113        1.1  macallan 
    114        1.4      jmmv 	/* accessops */
    115        1.6  christos 	int (*ioctl)(void *, void *, u_long, void *, int, struct lwp *);
    116        1.4      jmmv 
    117        1.1  macallan 	/* rasops */
    118        1.1  macallan 	void (*copycols)(void *, int, int, int, int);
    119        1.1  macallan 	void (*erasecols)(void *, int, int, int, long);
    120        1.1  macallan 	void (*copyrows)(void *, int, int, int);
    121        1.1  macallan 	void (*eraserows)(void *, int, int, long);
    122        1.1  macallan 	void (*cursor)(void *, int, int, int);
    123        1.8  macallan 	/* called before vcons_redraw_screen */
    124       1.26  macallan 	void *show_screen_cookie;
    125       1.26  macallan 	void (*show_screen_cb)(struct vcons_screen *, void *);
    126        1.1  macallan 	/* virtual screen management stuff */
    127        1.1  macallan 	void (*switch_cb)(void *, int, int);
    128        1.1  macallan 	void *switch_cb_arg;
    129        1.8  macallan 	struct callout switch_callout;
    130        1.1  macallan 	uint32_t switch_pending;
    131        1.1  macallan 	LIST_HEAD(, vcons_screen) screens;
    132        1.1  macallan 	struct vcons_screen *active, *wanted;
    133        1.1  macallan 	const struct wsscreen_descr *currenttype;
    134       1.25  macallan 	struct wsscreen_descr *defaulttype;
    135        1.1  macallan 	int switch_poll_count;
    136       1.14  jmcneill #ifdef VCONS_DRAW_INTR
    137       1.19  macallan 	int cells;
    138       1.19  macallan 	long *attrs;
    139       1.21  macallan 	uint32_t *chars;
    140       1.19  macallan 	int cursor_offset;
    141       1.14  jmcneill 	callout_t intr;
    142       1.17  jmcneill 	int intr_valid;
    143       1.16  jmcneill 	void *intr_softint;
    144       1.15  jmcneill 	int use_intr;		/* use intr drawing when non-zero */
    145       1.14  jmcneill #endif
    146        1.1  macallan };
    147        1.1  macallan 
    148  1.27.12.1   thorpej int	vcons_init(struct vcons_data *, void *, struct wsscreen_descr *,
    149  1.27.12.1   thorpej     struct wsdisplay_accessops *);
    150  1.27.12.1   thorpej int	vcons_earlyinit(struct vcons_data *, void *, struct wsscreen_descr *,
    151        1.1  macallan     struct wsdisplay_accessops *);
    152        1.1  macallan 
    153        1.1  macallan int	vcons_init_screen(struct vcons_data *, struct vcons_screen *, int,
    154        1.1  macallan     long *);
    155        1.1  macallan 
    156       1.19  macallan /* completely redraw the screen, clear it if RI_FULLCLEAR is set */
    157        1.1  macallan void	vcons_redraw_screen(struct vcons_screen *);
    158        1.1  macallan 
    159       1.19  macallan #ifdef VCONS_DRAW_INTR
    160       1.19  macallan /* redraw all dirty character cells */
    161       1.19  macallan void	vcons_update_screen(struct vcons_screen *);
    162       1.19  macallan void	vcons_invalidate_cache(struct vcons_data *);
    163       1.19  macallan #else
    164       1.19  macallan #define vcons_update_screen vcons_redraw_screen
    165       1.19  macallan #endif
    166       1.19  macallan 
    167       1.10  macallan void	vcons_replay_msgbuf(struct vcons_screen *);
    168        1.1  macallan 
    169       1.17  jmcneill void	vcons_enable_polling(struct vcons_data *);
    170       1.17  jmcneill void	vcons_disable_polling(struct vcons_data *);
    171       1.18  jmcneill void	vcons_hard_switch(struct vcons_screen *);
    172       1.17  jmcneill 
    173        1.1  macallan #endif /* _WSDISPLAY_VCONS_H_ */
    174