Deleted Added
full compact
vga_pci.c (189373) vga_pci.c (198251)
1/*-
2 * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2005 John Baldwin <jhb@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/pci/vga_pci.c 189373 2009-03-04 21:04:52Z jhb $");
31__FBSDID("$FreeBSD: head/sys/dev/pci/vga_pci.c 198251 2009-10-19 20:58:10Z jkim $");
32
33/*
34 * Simple driver for PCI VGA display devices. Drivers such as agp(4) and
35 * drm(4) should attach as children of this device.
36 *
37 * XXX: The vgapci name is a hack until we somehow merge the isa vga driver
38 * in or rename it.
39 */
40
41#include <sys/param.h>
42#include <sys/bus.h>
43#include <sys/kernel.h>
44#include <sys/module.h>
45#include <sys/rman.h>
32
33/*
34 * Simple driver for PCI VGA display devices. Drivers such as agp(4) and
35 * drm(4) should attach as children of this device.
36 *
37 * XXX: The vgapci name is a hack until we somehow merge the isa vga driver
38 * in or rename it.
39 */
40
41#include <sys/param.h>
42#include <sys/bus.h>
43#include <sys/kernel.h>
44#include <sys/module.h>
45#include <sys/rman.h>
46#include <sys/sysctl.h>
46#include <sys/systm.h>
47
48#include <dev/pci/pcireg.h>
49#include <dev/pci/pcivar.h>
50
51struct vga_resource {
52 struct resource *vr_res;
53 int vr_refs;
54};
55
56struct vga_pci_softc {
57 device_t vga_msi_child; /* Child driver using MSI. */
58 struct vga_resource vga_res[PCIR_MAX_BAR_0 + 1];
59};
60
47#include <sys/systm.h>
48
49#include <dev/pci/pcireg.h>
50#include <dev/pci/pcivar.h>
51
52struct vga_resource {
53 struct resource *vr_res;
54 int vr_refs;
55};
56
57struct vga_pci_softc {
58 device_t vga_msi_child; /* Child driver using MSI. */
59 struct vga_resource vga_res[PCIR_MAX_BAR_0 + 1];
60};
61
62SYSCTL_DECL(_hw_pci);
63
64int vga_pci_default_unit = -1;
65TUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit);
66SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RD,
67 &vga_pci_default_unit, -1, "Default VGA-compatible display");
68
61static int
62vga_pci_probe(device_t dev)
63{
69static int
70vga_pci_probe(device_t dev)
71{
72 device_t bdev;
73 int unit;
74 uint16_t bctl;
64
65 switch (pci_get_class(dev)) {
66 case PCIC_DISPLAY:
67 break;
68 case PCIC_OLD:
69 if (pci_get_subclass(dev) != PCIS_OLD_VGA)
70 return (ENXIO);
71 break;
72 default:
73 return (ENXIO);
74 }
75
76 switch (pci_get_class(dev)) {
77 case PCIC_DISPLAY:
78 break;
79 case PCIC_OLD:
80 if (pci_get_subclass(dev) != PCIS_OLD_VGA)
81 return (ENXIO);
82 break;
83 default:
84 return (ENXIO);
85 }
86
87 /* Probe default display. */
88 unit = device_get_unit(dev);
89 bdev = device_get_parent(device_get_parent(dev));
90 bctl = pci_read_config(bdev, PCIR_BRIDGECTL_1, 2);
91 if (vga_pci_default_unit < 0 && (bctl & PCIB_BCR_VGA_ENABLE) != 0)
92 vga_pci_default_unit = unit;
93 if (vga_pci_default_unit == unit)
94 device_set_flags(dev, 1);
95
75 device_set_desc(dev, "VGA-compatible display");
76 return (BUS_PROBE_GENERIC);
77}
78
79static int
80vga_pci_attach(device_t dev)
81{
82

--- 346 unchanged lines hidden ---
96 device_set_desc(dev, "VGA-compatible display");
97 return (BUS_PROBE_GENERIC);
98}
99
100static int
101vga_pci_attach(device_t dev)
102{
103

--- 346 unchanged lines hidden ---