From 5785a94163bfa31786a2059d7f03f216a7c232ae Mon Sep 17 00:00:00 2001 From: Rudolf Cornelissen Date: Tue, 13 Jul 2004 07:13:02 +0000 Subject: [PATCH] small agp update git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8389 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../private/graphics/nvidia/DriverInterface.h | 2 ++ .../accelerants/nvidia/engine/nv_agp.c | 30 ++++++++++++------- .../kernel/drivers/graphics/nvidia/driver.c | 4 +++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/headers/private/graphics/nvidia/DriverInterface.h b/headers/private/graphics/nvidia/DriverInterface.h index 01aa7e5488..4cd196e196 100644 --- a/headers/private/graphics/nvidia/DriverInterface.h +++ b/headers/private/graphics/nvidia/DriverInterface.h @@ -326,6 +326,7 @@ typedef struct { used (pre 3.x or 3.x) */ typedef struct { uint32 magic; /* magic number to make sure the caller groks us */ + bool agp_bus;/* indicates if we have access to the AGP busmanager */ uint8 index; /* device index in list of devices found */ bool exist; /* we got AGP device info */ agp_info agpi; /* AGP interface info of a device */ @@ -334,6 +335,7 @@ typedef struct { /* Execute an AGP command */ typedef struct { uint32 magic; /* magic number to make sure the caller groks us */ + bool agp_bus;/* indicates if we have access to the AGP busmanager */ uint32 cmd; /* actual command to execute */ } nv_cmd_agp; diff --git a/src/add-ons/accelerants/nvidia/engine/nv_agp.c b/src/add-ons/accelerants/nvidia/engine/nv_agp.c index cf870085fb..706f37ca85 100644 --- a/src/add-ons/accelerants/nvidia/engine/nv_agp.c +++ b/src/add-ons/accelerants/nvidia/engine/nv_agp.c @@ -15,8 +15,7 @@ status_t nv_agp_setup(void) nv_nth_agp_info nai; nv_cmd_agp nca; uint8 index; - uint8 nv_index = 0xff; - agp_info ai[8]; + agp_info nv_ai; bool agp = false; /* first try to enable FW support on our card if user requested this @@ -46,28 +45,37 @@ status_t nv_agp_setup(void) /* get nth AGP device info */ nai.index = index; ioctl(fd, NV_GET_NTH_AGP_INFO, &nai, sizeof(nai)); - /* exit if we didn't get one */ + + /* abort if no agp busmanager found */ + if (!nai.agp_bus) + { + LOG(4,("AGP: no AGP busmanager found.\n")); + + /* make sure the card is in PCI mode if it's an AGP type after all */ + CFGW(AGPCMD, 0x00000000); + + return B_ERROR; + } + + /* exit if we didn't get device info for this index */ if (!nai.exist) { if (index != 0) LOG(4,("AGP: end of AGP capable devices list.\n")); else - LOG(4,("AGP: no AGP busmanager or no AGP capable devices found.\n")); + LOG(4,("AGP: no AGP capable devices found.\n")); break; } LOG(4,("AGP: AGP capable device #%d:\n", (index + 1))); - /* remember the info we got */ - ai[index] = nai.agpi; - /* see if we are this one */ if (((((uint32)(nai.agpi.device_id)) << 16) | nai.agpi.vendor_id) == CFGR(DEVID)) { LOG(4,("AGP: (this is the device this accelerant controls)\n")); agp = true; - /* remember where we are */ - nv_index = index; + /* remember our info */ + nv_ai = nai.agpi; } /* log capabilities */ @@ -83,7 +91,7 @@ status_t nv_agp_setup(void) * We rely on the AGP busmanager to iterate trough this list for us. */ if (!agp) { - LOG(4,("AGP: assuming the graphicscard this accelerant controls is PCI type.\n")); + LOG(4,("AGP: the graphicscard this accelerant controls is PCI type.\n")); /* make sure the card is in PCI mode if it's an AGP type after all */ CFGW(AGPCMD, 0x00000000); @@ -108,7 +116,7 @@ status_t nv_agp_setup(void) /* let the AGP busmanager worry about what mode to set.. */ nca.cmd = (0xfffffff7); /* ..but we do need to select the right speed scheme fetched from our card */ - if (ai[nv_index].interface.agp_stat & AGP_rate_rev) nca.cmd |= AGP_rate_rev; + if (nv_ai.interface.agp_stat & AGP_rate_rev) nca.cmd |= AGP_rate_rev; ioctl(fd, NV_ENABLE_AGP, &nca, sizeof(nca)); /* list mode now activated */ diff --git a/src/add-ons/kernel/drivers/graphics/nvidia/driver.c b/src/add-ons/kernel/drivers/graphics/nvidia/driver.c index cc798c12c7..473cc91bc8 100644 --- a/src/add-ons/kernel/drivers/graphics/nvidia/driver.c +++ b/src/add-ons/kernel/drivers/graphics/nvidia/driver.c @@ -989,7 +989,9 @@ control_hook (void* dev, uint32 msg, void *buf, size_t len) { nv_nth_agp_info *nai = (nv_nth_agp_info *)buf; if (nai->magic == NV_PRIVATE_DATA_MAGIC) { nai->exist = false; + nai->agp_bus = false; if (agp_bus) { + nai->agp_bus = true; if ((*agp_bus->get_nth_agp_info)(nai->index, &(nai->agpi)) == B_NO_ERROR) { nai->exist = true; } @@ -1001,8 +1003,10 @@ control_hook (void* dev, uint32 msg, void *buf, size_t len) { nv_cmd_agp *nca = (nv_cmd_agp *)buf; if (nca->magic == NV_PRIVATE_DATA_MAGIC) { if (agp_bus) { + nca->agp_bus = true; (*agp_bus->enable_agp)(&(nca->cmd)); } else { + nca->agp_bus = false; nca->cmd = 0; } result = B_OK;