summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@secunet.com>2012-07-20 12:16:17 +0200
committerPatrick Georgi <patrick@georgi-clan.de>2012-07-22 13:10:44 +0200
commit557ecf2d31acef9ddcf7e0c9b47961c0ad36f57e (patch)
tree27cd71092b66fa7b8d64c6e3f586b8d96f7b9f2f
parent323a9236954cd847ad36c9b48b97fe9f74c49ea4 (diff)
downloadcoreboot-557ecf2d31acef9ddcf7e0c9b47961c0ad36f57e.tar.xz
Simplify VGA card discovery
We were handling vga, vga_first, vga_last, vga_onboard just to determine an onboard chip and the first plugin card. We were also traversing the devices manually instead of using the utility functions we have, for the chance that there are non-VGA cards we need to cope with (but why would they require VGA-style handling?) Change-Id: I8aa73aefa102725a64287f78a59de3d5dda1c7f2 Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Reviewed-on: http://review.coreboot.org/1255 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--src/devices/device.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/src/devices/device.c b/src/devices/device.c
index de27e88496..9753de81cb 100644
--- a/src/devices/device.c
+++ b/src/devices/device.c
@@ -715,52 +715,35 @@ static void set_vga_bridge_bits(void)
*/
/* FIXME: Handle the VGA palette snooping. */
- struct device *dev, *vga, *vga_onboard, *vga_first, *vga_last;
+ struct device *dev, *vga, *vga_onboard;
struct bus *bus;
bus = 0;
vga = 0;
vga_onboard = 0;
- vga_first = 0;
- vga_last = 0;
-
- for (dev = all_devices; dev; dev = dev->next) {
+ dev = NULL;
+ while ((dev = dev_find_class(PCI_CLASS_DISPLAY_VGA << 8, dev))) {
if (!dev->enabled)
continue;
- if (((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
- ((dev->class >> 8) != PCI_CLASS_DISPLAY_OTHER)) {
- if (!vga_first) {
- if (dev->on_mainboard)
- vga_onboard = dev;
- else
- vga_first = dev;
- } else {
- if (dev->on_mainboard)
- vga_onboard = dev;
- else
- vga_last = dev;
- }
+ printk(BIOS_DEBUG, "found VGA at %s\n", dev_path(dev));
- /* It isn't safe to enable other VGA cards. */
- dev->command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
+ if (dev->on_mainboard) {
+ vga_onboard = dev;
+ } else if (!vga) {
+ vga = dev;
}
- }
- vga = vga_last;
+ /* It isn't safe to enable all VGA cards. */
+ dev->command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
+ };
if (!vga)
- vga = vga_first;
+ vga = vga_onboard;
-#if CONFIG_ONBOARD_VGA_IS_PRIMARY
- if (vga_onboard) /* Will use onboard VGA as primary. */
-#else
- if (!vga) /* Will use last add-on adapter as primary. */
-#endif
- {
+ if (CONFIG_ONBOARD_VGA_IS_PRIMARY && vga_onboard)
vga = vga_onboard;
- }
/* If we prefer plugin VGA over chipset VGA, the chipset might
want to know. */