xref: /illumos-gate/usr/src/uts/i86pc/io/gfx_private/gfxp_fb.h (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 Toomas Soome <tsoome@me.com>
14  */
15 
16 #ifndef _GFXP_FB_H
17 #define	_GFXP_FB_H
18 
19 /*
20  * gfxp_fb interfaces.
21  */
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <sys/framebuffer.h>
28 #include <sys/vgareg.h>
29 #include <sys/vgasubr.h>
30 #include <sys/gfx_private.h>
31 
32 #define	GFXP_FLAG_CONSOLE	0x00000001
33 #define	GFXP_IS_CONSOLE(softc)	((softc)->flags & GFXP_FLAG_CONSOLE)
34 
35 struct gfxp_fb_softc;
36 
37 struct gfxp_ops {
38 	const struct vis_identifier *ident;
39 	int (*kdsetmode)(struct gfxp_fb_softc *softc, int mode);
40 	int (*devinit)(struct gfxp_fb_softc *, struct vis_devinit *data);
41 	void (*cons_copy)(struct gfxp_fb_softc *, struct vis_conscopy *);
42 	void (*cons_display)(struct gfxp_fb_softc *, struct vis_consdisplay *);
43 	void (*cons_cursor)(struct gfxp_fb_softc *, struct vis_conscursor *);
44 	int (*cons_clear)(struct gfxp_fb_softc *, struct vis_consclear *);
45 	int (*suspend)(struct gfxp_fb_softc *softc);
46 	void (*resume)(struct gfxp_fb_softc *softc);
47 	int (*devmap)(dev_t, devmap_cookie_t, offset_t, size_t, size_t *,
48 	    uint_t, void *);
49 };
50 
51 struct vgareg {
52 	unsigned char vga_misc;			/* Misc out reg */
53 	unsigned char vga_crtc[NUM_CRTC_REG];	/* Crtc controller */
54 	unsigned char vga_seq[NUM_SEQ_REG];	/* Video Sequencer */
55 	unsigned char vga_grc[NUM_GRC_REG];	/* Video Graphics */
56 	unsigned char vga_atr[NUM_ATR_REG];	/* Video Atribute */
57 };
58 
59 struct gfx_vga {
60 	struct vgaregmap regs;
61 	struct vgaregmap fb;
62 	off_t fb_size;
63 	int fb_regno;
64 	caddr_t	 text_base;	/* hardware text base */
65 	char shadow[VGA_TEXT_ROWS * VGA_TEXT_COLS * 2];
66 	caddr_t current_base;	/* hardware or shadow */
67 	char vga_fontslot;
68 	struct vgareg vga_reg;
69 	struct {
70 		boolean_t visible;
71 		int row;
72 		int col;
73 	} cursor;
74 	struct {
75 		unsigned char red;
76 		unsigned char green;
77 		unsigned char blue;
78 	} colormap[VGA8_CMAP_ENTRIES];
79 	unsigned char attrib_palette[VGA_ATR_NUM_PLT];
80 	struct font font;
81 };
82 
83 union gfx_console {
84 	struct fb_info fb;
85 	struct gfx_vga vga;
86 };
87 
88 struct gfxp_fb_softc {
89 	dev_info_t		*devi;
90 	int mode;		/* KD_TEXT or KD_GRAPHICS */
91 	enum gfxp_type		fb_type;
92 	unsigned int		flags;
93 	kmutex_t		lock;
94 	char			silent;
95 	char			happyface_boot;
96 	struct vis_polledio	polledio;
97 	struct gfxp_ops		*gfxp_ops;
98 	struct gfxp_blt_ops	blt_ops;
99 	struct fbgattr		*fbgattr;
100 	union gfx_console	*console;
101 };
102 
103 /* function definitions */
104 int gfxp_bm_attach(dev_info_t *, struct gfxp_fb_softc *);
105 int gfxp_bm_detach(dev_info_t *, struct gfxp_fb_softc *);
106 
107 int gfxp_vga_attach(dev_info_t *, struct gfxp_fb_softc *);
108 int gfxp_vga_detach(dev_info_t *, struct gfxp_fb_softc *);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* _GFXP_FB_H */
115