vgaarb.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #ifndef LINUX_VGA_H
  31. #define LINUX_VGA_H
  32. #include <video/vga.h>
  33. struct pci_dev;
  34. /* Legacy VGA regions */
  35. #define VGA_RSRC_NONE 0x00
  36. #define VGA_RSRC_LEGACY_IO 0x01
  37. #define VGA_RSRC_LEGACY_MEM 0x02
  38. #define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
  39. /* Non-legacy access */
  40. #define VGA_RSRC_NORMAL_IO 0x04
  41. #define VGA_RSRC_NORMAL_MEM 0x08
  42. #ifdef CONFIG_VGA_ARB
  43. void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes);
  44. int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
  45. void vga_put(struct pci_dev *pdev, unsigned int rsrc);
  46. struct pci_dev *vga_default_device(void);
  47. void vga_set_default_device(struct pci_dev *pdev);
  48. int vga_remove_vgacon(struct pci_dev *pdev);
  49. int vga_client_register(struct pci_dev *pdev,
  50. unsigned int (*set_decode)(struct pci_dev *pdev, bool state));
  51. #else /* CONFIG_VGA_ARB */
  52. static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
  53. unsigned int decodes)
  54. {
  55. };
  56. static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc,
  57. int interruptible)
  58. {
  59. return 0;
  60. }
  61. static inline void vga_put(struct pci_dev *pdev, unsigned int rsrc)
  62. {
  63. }
  64. static inline struct pci_dev *vga_default_device(void)
  65. {
  66. return NULL;
  67. }
  68. static inline void vga_set_default_device(struct pci_dev *pdev)
  69. {
  70. }
  71. static inline int vga_remove_vgacon(struct pci_dev *pdev)
  72. {
  73. return 0;
  74. }
  75. static inline int vga_client_register(struct pci_dev *pdev,
  76. unsigned int (*set_decode)(struct pci_dev *pdev, bool state))
  77. {
  78. return 0;
  79. }
  80. #endif /* CONFIG_VGA_ARB */
  81. /**
  82. * vga_get_interruptible
  83. * @pdev: pci device of the VGA card or NULL for the system default
  84. * @rsrc: bit mask of resources to acquire and lock
  85. *
  86. * Shortcut to vga_get with interruptible set to true.
  87. *
  88. * On success, release the VGA resource again with vga_put().
  89. */
  90. static inline int vga_get_interruptible(struct pci_dev *pdev,
  91. unsigned int rsrc)
  92. {
  93. return vga_get(pdev, rsrc, 1);
  94. }
  95. /**
  96. * vga_get_uninterruptible - shortcut to vga_get()
  97. * @pdev: pci device of the VGA card or NULL for the system default
  98. * @rsrc: bit mask of resources to acquire and lock
  99. *
  100. * Shortcut to vga_get with interruptible set to false.
  101. *
  102. * On success, release the VGA resource again with vga_put().
  103. */
  104. static inline int vga_get_uninterruptible(struct pci_dev *pdev,
  105. unsigned int rsrc)
  106. {
  107. return vga_get(pdev, rsrc, 0);
  108. }
  109. static inline void vga_client_unregister(struct pci_dev *pdev)
  110. {
  111. vga_client_register(pdev, NULL);
  112. }
  113. #endif /* LINUX_VGA_H */