Merge tag 'platform-drivers-x86-v5.18-1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / include / linux / vgaarb.h
CommitLineData
deb2d2ec 1/*
e2d4304b
JB
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.
deb2d2ec
BH
4 *
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>
c0db9cbc
TV
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 *
deb2d2ec
BH
29 */
30
31#ifndef LINUX_VGA_H
a6a1a095 32#define LINUX_VGA_H
deb2d2ec 33
1a39b310 34#include <video/vga.h>
deb2d2ec 35
6609176f
CH
36struct pci_dev;
37
deb2d2ec
BH
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
46
6609176f
CH
47#ifdef CONFIG_VGA_ARB
48void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes);
49int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
50void vga_put(struct pci_dev *pdev, unsigned int rsrc);
51struct pci_dev *vga_default_device(void);
52void vga_set_default_device(struct pci_dev *pdev);
53int vga_remove_vgacon(struct pci_dev *pdev);
bf44e8ce
CH
54int vga_client_register(struct pci_dev *pdev,
55 unsigned int (*set_decode)(struct pci_dev *pdev, bool state));
6609176f 56#else /* CONFIG_VGA_ARB */
0ea18b40 57static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
6609176f
CH
58 unsigned int decodes)
59{
60};
61static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc,
62 int interruptible)
63{
64 return 0;
65}
66static inline void vga_put(struct pci_dev *pdev, unsigned int rsrc)
67{
68}
69static inline struct pci_dev *vga_default_device(void)
70{
71 return NULL;
72}
73static inline void vga_set_default_device(struct pci_dev *pdev)
74{
75}
76static inline int vga_remove_vgacon(struct pci_dev *pdev)
77{
78 return 0;
79}
bf44e8ce
CH
80static inline int vga_client_register(struct pci_dev *pdev,
81 unsigned int (*set_decode)(struct pci_dev *pdev, bool state))
6609176f
CH
82{
83 return 0;
84}
85#endif /* CONFIG_VGA_ARB */
deb2d2ec
BH
86
87/**
b754b35b
DV
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
deb2d2ec 91 *
b754b35b
DV
92 * Shortcut to vga_get with interruptible set to true.
93 *
94 * On success, release the VGA resource again with vga_put().
deb2d2ec 95 */
deb2d2ec 96static inline int vga_get_interruptible(struct pci_dev *pdev,
6ac3bd52 97 unsigned int rsrc)
deb2d2ec
BH
98{
99 return vga_get(pdev, rsrc, 1);
100}
101
102/**
b754b35b
DV
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
deb2d2ec 106 *
b754b35b
DV
107 * Shortcut to vga_get with interruptible set to false.
108 *
109 * On success, release the VGA resource again with vga_put().
deb2d2ec 110 */
deb2d2ec 111static inline int vga_get_uninterruptible(struct pci_dev *pdev,
6ac3bd52 112 unsigned int rsrc)
deb2d2ec
BH
113{
114 return vga_get(pdev, rsrc, 0);
115}
116
b8779475
CH
117static inline void vga_client_unregister(struct pci_dev *pdev)
118{
bf44e8ce 119 vga_client_register(pdev, NULL);
b8779475
CH
120}
121
deb2d2ec 122#endif /* LINUX_VGA_H */