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 /*
17  * Generic framebuffer interface. Implementing common interfaces
18  * for bitmapped frame buffer and vgatext.
19  */
20 #include <sys/types.h>
21 #include <sys/ddi.h>
22 #include <sys/sunddi.h>
23 #include <sys/visual_io.h>
24 #include <sys/vgareg.h>
25 #include <sys/vgasubr.h>
26 
27 #include <sys/gfx_private.h>
28 #include "gfxp_fb.h"
29 
30 /* need to keep vgatext symbols for compatibility */
31 #pragma weak gfxp_vgatext_softc_alloc = gfxp_fb_softc_alloc
32 #pragma weak gfxp_vgatext_softc_free = gfxp_fb_softc_free
33 #pragma weak gfxp_vgatext_attach = gfxp_fb_attach
34 #pragma weak gfxp_vgatext_detach = gfxp_fb_detach
35 #pragma weak gfxp_vgatext_open = gfxp_fb_open
36 #pragma weak gfxp_vgatext_close = gfxp_fb_close
37 #pragma weak gfxp_vgatext_ioctl = gfxp_fb_ioctl
38 #pragma weak gfxp_vgatext_devmap = gfxp_fb_devmap
39 
40 gfxp_fb_softc_ptr_t
41 gfxp_fb_softc_alloc(void)
42 {
43 	return (kmem_zalloc(sizeof (struct gfxp_fb_softc), KM_SLEEP));
44 }
45 
46 void
47 gfxp_fb_softc_free(gfxp_fb_softc_ptr_t ptr)
48 {
49 	kmem_free(ptr, sizeof (struct gfxp_fb_softc));
50 }
51 
52 int
53 gfxp_fb_attach(dev_info_t *devi, ddi_attach_cmd_t cmd, gfxp_fb_softc_ptr_t ptr)
54 {
55 	return (gfxp_vga_attach(devi, cmd, ptr));
56 }
57 
58 int
59 gfxp_fb_detach(dev_info_t *devi, ddi_detach_cmd_t cmd, gfxp_fb_softc_ptr_t ptr)
60 {
61 	return (gfxp_vga_detach(devi, cmd, ptr));
62 }
63 
64 /*ARGSUSED*/
65 int
66 gfxp_fb_open(dev_t *devp, int flag, int otyp, cred_t *cred,
67     gfxp_fb_softc_ptr_t ptr)
68 {
69 	struct gfxp_fb_softc *softc = (struct gfxp_fb_softc *)ptr;
70 
71 	if (softc == NULL || otyp == OTYP_BLK)
72 		return (ENXIO);
73 
74 	return (0);
75 }
76 
77 /*ARGSUSED*/
78 int
79 gfxp_fb_close(dev_t devp, int flag, int otyp, cred_t *cred,
80     gfxp_fb_softc_ptr_t ptr)
81 {
82 	return (0);
83 }
84 
85 int
86 gfxp_fb_ioctl(dev_t dev, int cmd, intptr_t data, int mode,
87     cred_t *cred, int *rval, gfxp_fb_softc_ptr_t ptr)
88 {
89 	return (gfxp_vga_ioctl(dev, cmd, data, mode, cred, rval, ptr));
90 }
91 
92 int
93 gfxp_fb_devmap(dev_t dev, devmap_cookie_t dhp, offset_t off,
94     size_t len, size_t *maplen, uint_t model, void *ptr)
95 {
96 	return (gfxp_vga_devmap(dev, dhp, off, len, maplen, model, ptr));
97 }
98