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.
5 * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
6 * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com>
7 * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org>
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:
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
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
34 #include <video/vga.h>
38 /* Legacy VGA regions */
39 #define VGA_RSRC_NONE 0x00
40 #define VGA_RSRC_LEGACY_IO 0x01
41 #define VGA_RSRC_LEGACY_MEM 0x02
42 #define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
43 /* Non-legacy access */
44 #define VGA_RSRC_NORMAL_IO 0x04
45 #define VGA_RSRC_NORMAL_MEM 0x08
48 void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes);
49 int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
50 void vga_put(struct pci_dev *pdev, unsigned int rsrc);
51 struct pci_dev *vga_default_device(void);
52 void vga_set_default_device(struct pci_dev *pdev);
53 int vga_remove_vgacon(struct pci_dev *pdev);
54 int vga_client_register(struct pci_dev *pdev,
55 unsigned int (*set_decode)(struct pci_dev *pdev, bool state));
56 #else /* CONFIG_VGA_ARB */
57 static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
61 static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc,
66 static inline void vga_put(struct pci_dev *pdev, unsigned int rsrc)
69 static inline struct pci_dev *vga_default_device(void)
73 static inline void vga_set_default_device(struct pci_dev *pdev)
76 static inline int vga_remove_vgacon(struct pci_dev *pdev)
80 static inline int vga_client_register(struct pci_dev *pdev,
81 unsigned int (*set_decode)(struct pci_dev *pdev, bool state))
85 #endif /* CONFIG_VGA_ARB */
88 * vga_get_interruptible
89 * @pdev: pci device of the VGA card or NULL for the system default
90 * @rsrc: bit mask of resources to acquire and lock
92 * Shortcut to vga_get with interruptible set to true.
94 * On success, release the VGA resource again with vga_put().
96 static inline int vga_get_interruptible(struct pci_dev *pdev,
99 return vga_get(pdev, rsrc, 1);
103 * vga_get_uninterruptible - shortcut to vga_get()
104 * @pdev: pci device of the VGA card or NULL for the system default
105 * @rsrc: bit mask of resources to acquire and lock
107 * Shortcut to vga_get with interruptible set to false.
109 * On success, release the VGA resource again with vga_put().
111 static inline int vga_get_uninterruptible(struct pci_dev *pdev,
114 return vga_get(pdev, rsrc, 0);
117 static inline void vga_client_unregister(struct pci_dev *pdev)
119 vga_client_register(pdev, NULL);
122 #endif /* LINUX_VGA_H */