Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vgaarb.h
Go to the documentation of this file.
1 /*
2  * The VGA aribiter manages VGA space routing and VGA resource decode to
3  * allow multiple VGA devices to be used in a system in a safe way.
4  *
5  * (C) Copyright 2005 Benjamin Herrenschmidt <[email protected]>
6  * (C) Copyright 2007 Paulo R. Zanoni <[email protected]>
7  * (C) Copyright 2007, 2009 Tiago Vignatti <[email protected]>
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice (including the next
17  * paragraph) shall be included in all copies or substantial portions of the
18  * Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS
27  * IN THE SOFTWARE.
28  *
29  */
30 
31 #ifndef LINUX_VGA_H
32 #define LINUX_VGA_H
33 
34 #include <video/vga.h>
35 
36 /* Legacy VGA regions */
37 #define VGA_RSRC_NONE 0x00
38 #define VGA_RSRC_LEGACY_IO 0x01
39 #define VGA_RSRC_LEGACY_MEM 0x02
40 #define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
41 /* Non-legacy access */
42 #define VGA_RSRC_NORMAL_IO 0x04
43 #define VGA_RSRC_NORMAL_MEM 0x08
44 
45 /* Passing that instead of a pci_dev to use the system "default"
46  * device, that is the one used by vgacon. Archs will probably
47  * have to provide their own vga_default_device();
48  */
49 #define VGA_DEFAULT_DEVICE (NULL)
50 
51 struct pci_dev;
52 
53 /* For use by clients */
54 
68 extern void vga_set_legacy_decoding(struct pci_dev *pdev,
69  unsigned int decodes);
70 
99 #if defined(CONFIG_VGA_ARB)
100 extern int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
101 #else
102 static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible) { return 0; }
103 #endif
104 
111 static inline int vga_get_interruptible(struct pci_dev *pdev,
112  unsigned int rsrc)
113 {
114  return vga_get(pdev, rsrc, 1);
115 }
116 
123 static inline int vga_get_uninterruptible(struct pci_dev *pdev,
124  unsigned int rsrc)
125 {
126  return vga_get(pdev, rsrc, 0);
127 }
128 
140 #if defined(CONFIG_VGA_ARB)
141 extern int vga_tryget(struct pci_dev *pdev, unsigned int rsrc);
142 #else
143 static inline int vga_tryget(struct pci_dev *pdev, unsigned int rsrc) { return 0; }
144 #endif
145 
159 #if defined(CONFIG_VGA_ARB)
160 extern void vga_put(struct pci_dev *pdev, unsigned int rsrc);
161 #else
162 #define vga_put(pdev, rsrc)
163 #endif
164 
165 
185 #ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
186 #ifdef CONFIG_VGA_ARB
187 extern struct pci_dev *vga_default_device(void);
188 extern void vga_set_default_device(struct pci_dev *pdev);
189 #else
190 static inline struct pci_dev *vga_default_device(void) { return NULL; };
191 static inline void vga_set_default_device(struct pci_dev *pdev) { };
192 #endif
193 #endif
194 
203 #ifndef __ARCH_HAS_VGA_CONFLICT
204 static inline int vga_conflicts(struct pci_dev *p1, struct pci_dev *p2)
205 {
206  return 1;
207 }
208 #endif
209 
238 #if defined(CONFIG_VGA_ARB)
239 int vga_client_register(struct pci_dev *pdev, void *cookie,
240  void (*irq_set_state)(void *cookie, bool state),
241  unsigned int (*set_vga_decode)(void *cookie, bool state));
242 #else
243 static inline int vga_client_register(struct pci_dev *pdev, void *cookie,
244  void (*irq_set_state)(void *cookie, bool state),
245  unsigned int (*set_vga_decode)(void *cookie, bool state))
246 {
247  return 0;
248 }
249 #endif
250 
251 #endif /* LINUX_VGA_H */