| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: intelfb.c,v 1.11 2015/03/05 17:50:41 riastradh Exp $ */ | | 1 | /* $NetBSD: intelfb.c,v 1.12 2015/03/05 17:56:39 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,83 +20,66 @@ | | | @@ -20,83 +20,66 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: intelfb.c,v 1.11 2015/03/05 17:50:41 riastradh Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: intelfb.c,v 1.12 2015/03/05 17:56:39 riastradh Exp $"); |
34 | | | | |
35 | #ifdef _KERNEL_OPT | | | |
36 | #include "vga.h" | | | |
37 | #endif | | | |
38 | | | 34 | |
39 | #include <sys/types.h> | | 35 | #include <sys/types.h> |
40 | #include <sys/bus.h> | | 36 | #include <sys/bus.h> |
41 | #include <sys/device.h> | | 37 | #include <sys/device.h> |
42 | | | 38 | |
43 | #if NVGA > 0 | | | |
44 | /* | | | |
45 | * XXX All we really need is vga_is_console from vgavar.h, but the | | | |
46 | * header files are missing their own dependencies, so we need to | | | |
47 | * explicitly drag in the other crap. | | | |
48 | */ | | | |
49 | #include <dev/ic/mc6845reg.h> | | | |
50 | #include <dev/ic/pcdisplayvar.h> | | | |
51 | #include <dev/ic/vgareg.h> | | | |
52 | #include <dev/ic/vgavar.h> | | | |
53 | #endif | | | |
54 | | | | |
55 | #include <drm/drmP.h> | | 39 | #include <drm/drmP.h> |
56 | #include <drm/drmfb.h> | | 40 | #include <drm/drmfb.h> |
57 | #include <drm/drmfb_pci.h> | | 41 | #include <drm/drmfb_pci.h> |
58 | | | 42 | |
59 | #include "i915_drv.h" | | 43 | #include "i915_drv.h" |
60 | #include "i915_pci.h" | | 44 | #include "i915_pci.h" |
61 | #include "intelfb.h" | | 45 | #include "intelfb.h" |
62 | | | 46 | |
63 | static int intelfb_match(device_t, cfdata_t, void *); | | 47 | static int intelfb_match(device_t, cfdata_t, void *); |
64 | static void intelfb_attach(device_t, device_t, void *); | | 48 | static void intelfb_attach(device_t, device_t, void *); |
65 | static int intelfb_detach(device_t, int); | | 49 | static int intelfb_detach(device_t, int); |
66 | | | 50 | |
67 | static void intelfb_attach_task(struct i915drmkms_task *); | | 51 | static void intelfb_attach_task(struct i915drmkms_task *); |
68 | | | 52 | |
69 | static bool intel_is_vga_console(struct drm_device *); | | | |
70 | static bool intelfb_shutdown(device_t, int); | | 53 | static bool intelfb_shutdown(device_t, int); |
71 | | | 54 | |
72 | static paddr_t intelfb_drmfb_mmapfb(struct drmfb_softc *, off_t, int); | | 55 | static paddr_t intelfb_drmfb_mmapfb(struct drmfb_softc *, off_t, int); |
73 | | | 56 | |
74 | struct intelfb_softc { | | 57 | struct intelfb_softc { |
75 | struct drmfb_softc sc_drmfb; /* XXX Must be first. */ | | 58 | struct drmfb_softc sc_drmfb; /* XXX Must be first. */ |
76 | device_t sc_dev; | | 59 | device_t sc_dev; |
77 | struct intelfb_attach_args sc_ifa; | | 60 | struct intelfb_attach_args sc_ifa; |
78 | bus_space_handle_t sc_fb_bsh; | | 61 | bus_space_handle_t sc_fb_bsh; |
79 | struct i915drmkms_task sc_attach_task; | | 62 | struct i915drmkms_task sc_attach_task; |
80 | bool sc_mapped:1; | | 63 | bool sc_mapped:1; |
81 | bool sc_scheduled:1; | | 64 | bool sc_scheduled:1; |
82 | bool sc_attached:1; | | 65 | bool sc_attached:1; |
83 | }; | | 66 | }; |
84 | | | 67 | |
85 | static const struct drmfb_params intelfb_drmfb_params = { | | 68 | static const struct drmfb_params intelfb_drmfb_params = { |
86 | .dp_mmapfb = intelfb_drmfb_mmapfb, | | 69 | .dp_mmapfb = intelfb_drmfb_mmapfb, |
87 | .dp_mmap = drmfb_pci_mmap, | | 70 | .dp_mmap = drmfb_pci_mmap, |
88 | .dp_ioctl = drmfb_pci_ioctl, | | 71 | .dp_ioctl = drmfb_pci_ioctl, |
89 | .dp_is_vga_console = intel_is_vga_console, | | 72 | .dp_is_vga_console = drmfb_pci_is_vga_console, |
90 | .dp_disable_vga = i915_disable_vga, | | 73 | .dp_disable_vga = i915_disable_vga, |
91 | }; | | 74 | }; |
92 | | | 75 | |
93 | CFATTACH_DECL_NEW(intelfb, sizeof(struct intelfb_softc), | | 76 | CFATTACH_DECL_NEW(intelfb, sizeof(struct intelfb_softc), |
94 | intelfb_match, intelfb_attach, intelfb_detach, NULL); | | 77 | intelfb_match, intelfb_attach, intelfb_detach, NULL); |
95 | | | 78 | |
96 | static int | | 79 | static int |
97 | intelfb_match(device_t parent, cfdata_t match, void *aux) | | 80 | intelfb_match(device_t parent, cfdata_t match, void *aux) |
98 | { | | 81 | { |
99 | | | 82 | |
100 | return 1; | | 83 | return 1; |
101 | } | | 84 | } |
102 | | | 85 | |
| @@ -195,37 +178,26 @@ intelfb_attach_task(struct i915drmkms_ta | | | @@ -195,37 +178,26 @@ intelfb_attach_task(struct i915drmkms_ta |
195 | aprint_error_dev(sc->sc_dev, "failed to attach drmfb: %d\n", | | 178 | aprint_error_dev(sc->sc_dev, "failed to attach drmfb: %d\n", |
196 | error); | | 179 | error); |
197 | return; | | 180 | return; |
198 | } | | 181 | } |
199 | | | 182 | |
200 | if (pmf_device_register1(sc->sc_dev, NULL, NULL, &intelfb_shutdown)) | | 183 | if (pmf_device_register1(sc->sc_dev, NULL, NULL, &intelfb_shutdown)) |
201 | aprint_error_dev(sc->sc_dev, | | 184 | aprint_error_dev(sc->sc_dev, |
202 | "failed to register shutdown handler\n"); | | 185 | "failed to register shutdown handler\n"); |
203 | | | 186 | |
204 | sc->sc_attached = true; | | 187 | sc->sc_attached = true; |
205 | } | | 188 | } |
206 | | | 189 | |
207 | static bool | | 190 | static bool |
208 | intel_is_vga_console(struct drm_device *dev) | | | |
209 | { | | | |
210 | | | | |
211 | #if NVGA > 0 | | | |
212 | return vga_is_console(dev->pdev->pd_pa.pa_iot, -1); | | | |
213 | #else | | | |
214 | return false; | | | |
215 | #endif | | | |
216 | } | | | |
217 | | | | |
218 | static bool | | | |
219 | intelfb_shutdown(device_t self, int flags) | | 191 | intelfb_shutdown(device_t self, int flags) |
220 | { | | 192 | { |
221 | struct intelfb_softc *const sc = device_private(self); | | 193 | struct intelfb_softc *const sc = device_private(self); |
222 | | | 194 | |
223 | return drmfb_shutdown(&sc->sc_drmfb, flags); | | 195 | return drmfb_shutdown(&sc->sc_drmfb, flags); |
224 | } | | 196 | } |
225 | | | 197 | |
226 | static paddr_t | | 198 | static paddr_t |
227 | intelfb_drmfb_mmapfb(struct drmfb_softc *drmfb, off_t offset, int prot) | | 199 | intelfb_drmfb_mmapfb(struct drmfb_softc *drmfb, off_t offset, int prot) |
228 | { | | 200 | { |
229 | struct intelfb_softc *const sc = container_of(drmfb, | | 201 | struct intelfb_softc *const sc = container_of(drmfb, |
230 | struct intelfb_softc, sc_drmfb); | | 202 | struct intelfb_softc, sc_drmfb); |
231 | struct drm_fb_helper *const helper = sc->sc_ifa.ifa_fb_helper; | | 203 | struct drm_fb_helper *const helper = sc->sc_ifa.ifa_fb_helper; |