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