Thu Mar 5 17:56:39 2015 UTC ()
Factor out intelfb_is_vga_console to drmfb_pci.


(riastradh)
diff -r1.11 -r1.12 src/sys/external/bsd/drm2/i915drm/intelfb.c
diff -r1.1 -r1.2 src/sys/external/bsd/drm2/include/drm/drmfb_pci.h
diff -r1.1 -r1.2 src/sys/external/bsd/drm2/pci/drmfb_pci.c

cvs diff -r1.11 -r1.12 src/sys/external/bsd/drm2/i915drm/intelfb.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/i915drm/intelfb.c 2015/03/05 17:50:41 1.11
+++ src/sys/external/bsd/drm2/i915drm/intelfb.c 2015/03/05 17:56:39 1.12
@@ -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
63static int intelfb_match(device_t, cfdata_t, void *); 47static int intelfb_match(device_t, cfdata_t, void *);
64static void intelfb_attach(device_t, device_t, void *); 48static void intelfb_attach(device_t, device_t, void *);
65static int intelfb_detach(device_t, int); 49static int intelfb_detach(device_t, int);
66 50
67static void intelfb_attach_task(struct i915drmkms_task *); 51static void intelfb_attach_task(struct i915drmkms_task *);
68 52
69static bool intel_is_vga_console(struct drm_device *); 
70static bool intelfb_shutdown(device_t, int); 53static bool intelfb_shutdown(device_t, int);
71 54
72static paddr_t intelfb_drmfb_mmapfb(struct drmfb_softc *, off_t, int); 55static paddr_t intelfb_drmfb_mmapfb(struct drmfb_softc *, off_t, int);
73 56
74struct intelfb_softc { 57struct 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
85static const struct drmfb_params intelfb_drmfb_params = { 68static 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
93CFATTACH_DECL_NEW(intelfb, sizeof(struct intelfb_softc), 76CFATTACH_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
96static int 79static int
97intelfb_match(device_t parent, cfdata_t match, void *aux) 80intelfb_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
207static bool 190static bool
208intel_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 
218static bool 
219intelfb_shutdown(device_t self, int flags) 191intelfb_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
226static paddr_t 198static paddr_t
227intelfb_drmfb_mmapfb(struct drmfb_softc *drmfb, off_t offset, int prot) 199intelfb_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;

cvs diff -r1.1 -r1.2 src/sys/external/bsd/drm2/include/drm/drmfb_pci.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/include/drm/drmfb_pci.h 2015/03/05 17:50:41 1.1
+++ src/sys/external/bsd/drm2/include/drm/drmfb_pci.h 2015/03/05 17:56:39 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drmfb_pci.h,v 1.1 2015/03/05 17:50:41 riastradh Exp $ */ 1/* $NetBSD: drmfb_pci.h,v 1.2 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.
@@ -30,15 +30,16 @@ @@ -30,15 +30,16 @@
30 */ 30 */
31 31
32#ifndef _DRM_DRMFB_PCI_H_ 32#ifndef _DRM_DRMFB_PCI_H_
33#define _DRM_DRMFB_PCI_H_ 33#define _DRM_DRMFB_PCI_H_
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37struct drmfb_softc; 37struct drmfb_softc;
38struct lwp; 38struct lwp;
39 39
40paddr_t drmfb_pci_mmap(struct drmfb_softc *, off_t, int); 40paddr_t drmfb_pci_mmap(struct drmfb_softc *, off_t, int);
41int drmfb_pci_ioctl(struct drmfb_softc *, unsigned long, void *, int, 41int drmfb_pci_ioctl(struct drmfb_softc *, unsigned long, void *, int,
42 struct lwp *); 42 struct lwp *);
 43bool drmfb_pci_is_vga_console(struct drm_device *);
43 44
44#endif /* _DRM_DRMFB_PCI_H_ */ 45#endif /* _DRM_DRMFB_PCI_H_ */

cvs diff -r1.1 -r1.2 src/sys/external/bsd/drm2/pci/drmfb_pci.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/pci/drmfb_pci.c 2015/03/05 17:50:41 1.1
+++ src/sys/external/bsd/drm2/pci/drmfb_pci.c 2015/03/05 17:56:39 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: drmfb_pci.c,v 1.1 2015/03/05 17:50:41 riastradh Exp $ */ 1/* $NetBSD: drmfb_pci.c,v 1.2 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.
@@ -24,38 +24,54 @@ @@ -24,38 +24,54 @@
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/* 32/*
33 * drmfb_pci: drmfb hooks for PCI devices. 33 * drmfb_pci: drmfb hooks for PCI devices.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: drmfb_pci.c,v 1.1 2015/03/05 17:50:41 riastradh Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: drmfb_pci.c,v 1.2 2015/03/05 17:56:39 riastradh Exp $");
 38
 39#ifdef _KERNEL_OPT
 40#include "vga.h"
 41#endif
38 42
39#include <sys/types.h> 43#include <sys/types.h>
40#include <sys/device.h> 44#include <sys/device.h>
41#include <sys/errno.h> 45#include <sys/errno.h>
42#include <sys/systm.h> 46#include <sys/systm.h>
43 47
44#include <dev/pci/pciio.h> 48#include <dev/pci/pciio.h>
45#include <dev/pci/pcireg.h> 49#include <dev/pci/pcireg.h>
46#include <dev/pci/pcivar.h> 50#include <dev/pci/pcivar.h>
47#include <dev/pci/wsdisplay_pci.h> 51#include <dev/pci/wsdisplay_pci.h>
48 52
 53#if NVGA > 0
 54/*
 55 * XXX All we really need is vga_is_console from vgavar.h, but the
 56 * header files are missing their own dependencies, so we need to
 57 * explicitly drag in the other crap.
 58 */
 59#include <dev/ic/mc6845reg.h>
 60#include <dev/ic/pcdisplayvar.h>
 61#include <dev/ic/vgareg.h>
 62#include <dev/ic/vgavar.h>
 63#endif
 64
49#include <drm/drmP.h> 65#include <drm/drmP.h>
50#include <drm/drm_fb_helper.h> 66#include <drm/drm_fb_helper.h>
51 67
52#include "drmfb.h" 68#include "drmfb.h"
53#include "drmfb_pci.h" 69#include "drmfb_pci.h"
54 70
55/* 71/*
56 * drmfb_pci_mmap: Implementation of drmfb_params::dp_mmap. Don't use 72 * drmfb_pci_mmap: Implementation of drmfb_params::dp_mmap. Don't use
57 * this for dp_mmapfb -- how to get at the framebuffer is device- 73 * this for dp_mmapfb -- how to get at the framebuffer is device-
58 * specific. 74 * specific.
59 */ 75 */
60paddr_t 76paddr_t
61drmfb_pci_mmap(struct drmfb_softc *sc, off_t offset, int prot) 77drmfb_pci_mmap(struct drmfb_softc *sc, off_t offset, int prot)
@@ -122,13 +138,24 @@ drmfb_pci_ioctl(struct drmfb_softc *sc,  @@ -122,13 +138,24 @@ drmfb_pci_ioctl(struct drmfb_softc *sc,
122 138
123 /* PCI-specific wsdisplay ioctls. */ 139 /* PCI-specific wsdisplay ioctls. */
124 case WSDISPLAYIO_GET_BUSID: 140 case WSDISPLAYIO_GET_BUSID:
125 return wsdisplayio_busid_pci(dev->dev, pa->pa_pc, pa->pa_tag, 141 return wsdisplayio_busid_pci(dev->dev, pa->pa_pc, pa->pa_tag,
126 data); 142 data);
127 case WSDISPLAYIO_GTYPE: 143 case WSDISPLAYIO_GTYPE:
128 *(unsigned int *)data = WSDISPLAY_TYPE_PCIVGA; 144 *(unsigned int *)data = WSDISPLAY_TYPE_PCIVGA;
129 return 0; 145 return 0;
130 146
131 default: 147 default:
132 return EPASSTHROUGH; 148 return EPASSTHROUGH;
133 } 149 }
134} 150}
 151
 152bool
 153drmfb_pci_is_vga_console(struct drm_device *dev)
 154{
 155
 156#if NVGA > 0
 157 return vga_is_console(dev->pdev->pd_pa.pa_iot, -1);
 158#else
 159 return false;
 160#endif
 161}