xref: /illumos-gate/usr/src/uts/i86pc/io/gfx_private/gfxp_fb.h (revision 0bead3cac461a1ad4d49bae1dc8a3be05110aa74)
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 typedef struct {
36 	uint8_t red[16];
37 	uint8_t green[16];
38 	uint8_t blue[16];
39 } text_cmap_t;
40 
41 extern text_cmap_t cmap_rgb16;
42 
43 struct gfxp_fb_softc;
44 
45 struct gfxp_ops {
46 	const struct vis_identifier *ident;
47 	int (*kdsetmode)(struct gfxp_fb_softc *softc, int mode);
48 	int (*devinit)(struct gfxp_fb_softc *, struct vis_devinit *data);
49 	void (*cons_copy)(struct gfxp_fb_softc *, struct vis_conscopy *);
50 	void (*cons_display)(struct gfxp_fb_softc *, struct vis_consdisplay *);
51 	void (*cons_cursor)(struct gfxp_fb_softc *, struct vis_conscursor *);
52 	int (*cons_clear)(struct gfxp_fb_softc *, struct vis_consclear *);
53 	int (*suspend)(struct gfxp_fb_softc *softc);
54 	void (*resume)(struct gfxp_fb_softc *softc);
55 	int (*devmap)(dev_t, devmap_cookie_t, offset_t, size_t, size_t *,
56 	    uint_t, void *);
57 };
58 
59 struct vgareg {
60 	unsigned char vga_misc;			/* Misc out reg */
61 	unsigned char vga_crtc[NUM_CRTC_REG];	/* Crtc controller */
62 	unsigned char vga_seq[NUM_SEQ_REG];	/* Video Sequencer */
63 	unsigned char vga_grc[NUM_GRC_REG];	/* Video Graphics */
64 	unsigned char vga_atr[NUM_ATR_REG];	/* Video Atribute */
65 };
66 
67 struct gfx_vga {
68 	struct vgaregmap regs;
69 	struct vgaregmap fb;
70 	off_t fb_size;
71 	int fb_regno;
72 	caddr_t	 text_base;	/* hardware text base */
73 	char shadow[VGA_TEXT_ROWS * VGA_TEXT_COLS * 2];
74 	caddr_t current_base;	/* hardware or shadow */
75 	char vga_fontslot;
76 	struct vgareg vga_reg;
77 	struct {
78 		boolean_t visible;
79 		int row;
80 		int col;
81 	} cursor;
82 	struct {
83 		unsigned char red;
84 		unsigned char green;
85 		unsigned char blue;
86 	} colormap[VGA8_CMAP_ENTRIES];
87 	unsigned char attrib_palette[VGA_ATR_NUM_PLT];
88 };
89 
90 union gfx_console {
91 	struct fb_info fb;
92 	struct gfx_vga vga;
93 };
94 
95 struct gfxp_fb_softc {
96 	dev_info_t		*devi;
97 	int mode;		/* KD_TEXT or KD_GRAPHICS */
98 	enum gfxp_type		fb_type;
99 	unsigned int		flags;
100 	kmutex_t		lock;
101 	char			silent;
102 	char			happyface_boot;
103 	struct vis_polledio	polledio;
104 	struct gfxp_ops		*gfxp_ops;
105 	struct gfxp_blt_ops	blt_ops;
106 	struct fbgattr		*fbgattr;
107 	union gfx_console	*console;
108 };
109 
110 /* function definitions */
111 int gfxp_bm_attach(dev_info_t *, struct gfxp_fb_softc *);
112 int gfxp_bm_detach(dev_info_t *, struct gfxp_fb_softc *);
113 
114 int gfxp_vga_attach(dev_info_t *, struct gfxp_fb_softc *);
115 int gfxp_vga_detach(dev_info_t *, struct gfxp_fb_softc *);
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif /* _GFXP_FB_H */
122