1 /* SPDX-License-Identifier: MIT */
4 * The VGA aribiter manages VGA space routing and VGA resource decode to
5 * allow multiple VGA devices to be used in a system in a safe way.
7 * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
8 * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com>
9 * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org>
15 #include <video/vga.h>
19 /* Legacy VGA regions */
20 #define VGA_RSRC_NONE 0x00
21 #define VGA_RSRC_LEGACY_IO 0x01
22 #define VGA_RSRC_LEGACY_MEM 0x02
23 #define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
24 /* Non-legacy access */
25 #define VGA_RSRC_NORMAL_IO 0x04
26 #define VGA_RSRC_NORMAL_MEM 0x08
29 void vga_set_legacy_decoding(struct pci_dev
*pdev
, unsigned int decodes
);
30 int vga_get(struct pci_dev
*pdev
, unsigned int rsrc
, int interruptible
);
31 void vga_put(struct pci_dev
*pdev
, unsigned int rsrc
);
32 struct pci_dev
*vga_default_device(void);
33 void vga_set_default_device(struct pci_dev
*pdev
);
34 int vga_remove_vgacon(struct pci_dev
*pdev
);
35 int vga_client_register(struct pci_dev
*pdev
,
36 unsigned int (*set_decode
)(struct pci_dev
*pdev
, bool state
));
37 #else /* CONFIG_VGA_ARB */
38 static inline void vga_set_legacy_decoding(struct pci_dev
*pdev
,
42 static inline int vga_get(struct pci_dev
*pdev
, unsigned int rsrc
,
47 static inline void vga_put(struct pci_dev
*pdev
, unsigned int rsrc
)
50 static inline struct pci_dev
*vga_default_device(void)
54 static inline void vga_set_default_device(struct pci_dev
*pdev
)
57 static inline int vga_remove_vgacon(struct pci_dev
*pdev
)
61 static inline int vga_client_register(struct pci_dev
*pdev
,
62 unsigned int (*set_decode
)(struct pci_dev
*pdev
, bool state
))
66 #endif /* CONFIG_VGA_ARB */
69 * vga_get_interruptible
70 * @pdev: pci device of the VGA card or NULL for the system default
71 * @rsrc: bit mask of resources to acquire and lock
73 * Shortcut to vga_get with interruptible set to true.
75 * On success, release the VGA resource again with vga_put().
77 static inline int vga_get_interruptible(struct pci_dev
*pdev
,
80 return vga_get(pdev
, rsrc
, 1);
84 * vga_get_uninterruptible - shortcut to vga_get()
85 * @pdev: pci device of the VGA card or NULL for the system default
86 * @rsrc: bit mask of resources to acquire and lock
88 * Shortcut to vga_get with interruptible set to false.
90 * On success, release the VGA resource again with vga_put().
92 static inline int vga_get_uninterruptible(struct pci_dev
*pdev
,
95 return vga_get(pdev
, rsrc
, 0);
98 static inline void vga_client_unregister(struct pci_dev
*pdev
)
100 vga_client_register(pdev
, NULL
);
103 #endif /* LINUX_VGA_H */