1 /* $OpenBSD: vga_pcivar.h,v 1.7 2006/11/27 18:04:28 gwk Exp $ */
2 /* $NetBSD: vga_pcivar.h,v 1.1 1998/03/22 15:16:19 drochner Exp $ */
3
4 /*
5 * Copyright (c) 1995, 1996 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Author: Chris G. Demetriou
9 *
10 * Permission to use, copy, modify and distribute this software and
11 * its documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
23 * School of Computer Science
24 * Carnegie Mellon University
25 * Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
29 */
30
31 #ifndef _PCI_VGA_PCIVAR_H_
32 #define _PCI_VGA_PCIVAR_H_
33
34 #define DEVICE_IS_VGA_PCI(class, id) \
35 (((PCI_CLASS(class) == PCI_CLASS_DISPLAY && \
36 PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_VGA) || \
37 (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && \
38 PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) ? 1 : 0)
39
40 enum agp_acquire_state {
41 AGP_ACQUIRE_FREE,
42 AGP_ACQUIRE_USER,
43 AGP_ACQUIRE_KERNEL
44 };
45
46 /*
47 * Data structure to describe an AGP memory allocation.
48 */
49 TAILQ_HEAD(agp_memory_list, agp_memory);
50 struct agp_memory {
51 TAILQ_ENTRY(agp_memory) am_link; /* wiring for the tailq */
52 int am_id; /* unique id for block */
53 vsize_t am_size; /* number of bytes allocated */
54 int am_type; /* chipset specific type */
55 off_t am_offset; /* page offset if bound */
56 int am_is_bound; /* non-zero if bound */
57 bus_addr_t am_physical;
58 caddr_t am_virtual;
59 bus_dmamap_t am_dmamap;
60 int am_nseg;
61 bus_dma_segment_t *am_dmaseg;
62 };
63
64 struct vga_pci_softc {
65 struct device sc_dev;
66
67 #if 0
68 struct vga_config *sc_vc; /* VGA configuration */
69 #endif
70 #ifdef VESAFB
71 int sc_width;
72 int sc_height;
73 int sc_depth;
74 int sc_linebytes;
75 u_int32_t sc_base;
76 int sc_mode; /* WSDISPLAY_MODE_EMUL or _DUMBFB */
77 int sc_textmode; /* original VESA text mode */
78 int sc_gfxmode; /* VESA graphics mode */
79 u_char sc_cmap_red[256]; /* saved color map */
80 u_char sc_cmap_green[256];
81 u_char sc_cmap_blue[256];
82
83 #endif
84 #ifdef PCIAGP
85 /* agp stuff */
86 bus_space_tag_t sc_bt, sc_memt;
87 bus_space_handle_t sc_bh;
88 bus_addr_t sc_apaddr;
89 bus_size_t sc_apsize;
90 bus_dma_tag_t sc_dmat;
91 struct lock sc_lock; /* lock for access to GATT */
92 pcitag_t sc_pcitag; /* PCI tag, in case we need it. */
93 pcireg_t sc_id;
94 pci_chipset_tag_t sc_pc;
95
96 struct agp_methods *sc_methods;
97 void *sc_chipc; /* chipset-dependent state */
98
99 int sc_opened;
100 int sc_capoff;
101 int sc_apflags;
102 int sc_nextid; /* next memory block id */
103
104 u_int32_t sc_maxmem; /* allocation upper bound */
105 u_int32_t sc_allocated; /* amount allocated */
106 enum agp_acquire_state sc_state;
107 struct agp_memory_list sc_memory; /* list of allocated memory */
108 #endif
109 };
110
111 #ifdef PCIAGP
112 struct agp_product {
113 int ap_vendor;
114 int ap_product;
115 int (*ap_attach)(struct vga_pci_softc *,
116 struct pci_attach_args *, struct pci_attach_args *);
117 };
118 /* MD-defined */
119 extern const struct agp_product agp_products[];
120
121 void agp_attach(struct device *, struct device *, void *);
122 paddr_t agp_mmap(void *, off_t, int);
123 int agp_ioctl(void *, u_long, caddr_t, int, struct proc *);
124 #endif /* PCIAGP */
125
126 int vga_pci_cnattach(bus_space_tag_t, bus_space_tag_t,
127 pci_chipset_tag_t, int, int, int);
128
129 #ifdef VESAFB
130 int vesafb_find_mode(struct vga_pci_softc *, int, int, int);
131 void vesafb_set_mode(struct vga_pci_softc *, int);
132 int vesafb_get_mode(struct vga_pci_softc *);
133 int vesafb_get_supported_depth(struct vga_pci_softc *);
134 #endif
135
136 #endif /* _PCI_VGA_PCIVAR_H_ */