Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * The VGA aribiter manages VGA space routing and VGA resource decode to
0003  * allow multiple VGA devices to be used in a system in a safe way.
0004  *
0005  * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
0006  * (C) Copyright 2007 Paulo R. Zanoni <przanoni@gmail.com>
0007  * (C) Copyright 2007, 2009 Tiago Vignatti <vignatti@freedesktop.org>
0008  *
0009  * Permission is hereby granted, free of charge, to any person obtaining a
0010  * copy of this software and associated documentation files (the "Software"),
0011  * to deal in the Software without restriction, including without limitation
0012  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0013  * and/or sell copies of the Software, and to permit persons to whom the
0014  * Software is furnished to do so, subject to the following conditions:
0015  *
0016  * The above copyright notice and this permission notice (including the next
0017  * paragraph) shall be included in all copies or substantial portions of the
0018  * Software.
0019  *
0020  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0021  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0022  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0023  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0024  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0025  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0026  * DEALINGS
0027  * IN THE SOFTWARE.
0028  *
0029  */
0030 
0031 #ifndef LINUX_VGA_H
0032 #define LINUX_VGA_H
0033 
0034 #include <video/vga.h>
0035 
0036 struct pci_dev;
0037 
0038 /* Legacy VGA regions */
0039 #define VGA_RSRC_NONE          0x00
0040 #define VGA_RSRC_LEGACY_IO     0x01
0041 #define VGA_RSRC_LEGACY_MEM    0x02
0042 #define VGA_RSRC_LEGACY_MASK   (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
0043 /* Non-legacy access */
0044 #define VGA_RSRC_NORMAL_IO     0x04
0045 #define VGA_RSRC_NORMAL_MEM    0x08
0046 
0047 #ifdef CONFIG_VGA_ARB
0048 void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes);
0049 int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
0050 void vga_put(struct pci_dev *pdev, unsigned int rsrc);
0051 struct pci_dev *vga_default_device(void);
0052 void vga_set_default_device(struct pci_dev *pdev);
0053 int vga_remove_vgacon(struct pci_dev *pdev);
0054 int vga_client_register(struct pci_dev *pdev,
0055         unsigned int (*set_decode)(struct pci_dev *pdev, bool state));
0056 #else /* CONFIG_VGA_ARB */
0057 static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
0058         unsigned int decodes)
0059 {
0060 };
0061 static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc,
0062         int interruptible)
0063 {
0064     return 0;
0065 }
0066 static inline void vga_put(struct pci_dev *pdev, unsigned int rsrc)
0067 {
0068 }
0069 static inline struct pci_dev *vga_default_device(void)
0070 {
0071     return NULL;
0072 }
0073 static inline void vga_set_default_device(struct pci_dev *pdev)
0074 {
0075 }
0076 static inline int vga_remove_vgacon(struct pci_dev *pdev)
0077 {
0078     return 0;
0079 }
0080 static inline int vga_client_register(struct pci_dev *pdev,
0081         unsigned int (*set_decode)(struct pci_dev *pdev, bool state))
0082 {
0083     return 0;
0084 }
0085 #endif /* CONFIG_VGA_ARB */
0086 
0087 /**
0088  * vga_get_interruptible
0089  * @pdev: pci device of the VGA card or NULL for the system default
0090  * @rsrc: bit mask of resources to acquire and lock
0091  *
0092  * Shortcut to vga_get with interruptible set to true.
0093  *
0094  * On success, release the VGA resource again with vga_put().
0095  */
0096 static inline int vga_get_interruptible(struct pci_dev *pdev,
0097                     unsigned int rsrc)
0098 {
0099        return vga_get(pdev, rsrc, 1);
0100 }
0101 
0102 /**
0103  * vga_get_uninterruptible - shortcut to vga_get()
0104  * @pdev: pci device of the VGA card or NULL for the system default
0105  * @rsrc: bit mask of resources to acquire and lock
0106  *
0107  * Shortcut to vga_get with interruptible set to false.
0108  *
0109  * On success, release the VGA resource again with vga_put().
0110  */
0111 static inline int vga_get_uninterruptible(struct pci_dev *pdev,
0112                       unsigned int rsrc)
0113 {
0114        return vga_get(pdev, rsrc, 0);
0115 }
0116 
0117 static inline void vga_client_unregister(struct pci_dev *pdev)
0118 {
0119     vga_client_register(pdev, NULL);
0120 }
0121 
0122 #endif /* LINUX_VGA_H */