From 4f4035561fa312e2059e8a28ed0cb538f0b9a15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 2 May 2006 20:17:45 +0000 Subject: [PATCH] Hacked AccelerantHWInterface::GetDriverPath() to call the accelerants B_GET_ACCELERANT_CLONE_INFO (as that's what the caller actually wants). Unfortunately, it's currently hard-coded to path names, that is, if there is a driver out there that doesn't follow this quasi standard, it will break this mechanism. We should either change the driver interface to explicetly use path names, or change the mechanism we're using (in BWindowScreen upwards to the app_server) to the one as thought by Be. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17299 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerApp.cpp | 4 +-- .../app/drawing/AccelerantHWInterface.cpp | 34 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index cff603322f..aa03fc0445 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -2325,13 +2325,13 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) { int32 index; fLink.Read(&index); - + BString path; status_t status = fDesktop->HWInterface()->GetDriverPath(path); fLink.StartMessage(status); if (status == B_OK) fLink.AttachString(path.String()); - + fLink.Flush(); break; } diff --git a/src/servers/app/drawing/AccelerantHWInterface.cpp b/src/servers/app/drawing/AccelerantHWInterface.cpp index 62a9caac1c..0d5e58c4a7 100644 --- a/src/servers/app/drawing/AccelerantHWInterface.cpp +++ b/src/servers/app/drawing/AccelerantHWInterface.cpp @@ -187,21 +187,21 @@ AccelerantHWInterface::_OpenGraphicsDevice(int deviceNumber) // removed. int count = 0; struct dirent *entry; - int current_card_fd = -1; + int device = -1; char path[PATH_MAX]; while (count < deviceNumber && (entry = readdir(directory)) != NULL) { if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..") || !strcmp(entry->d_name, "stub") || !strcmp(entry->d_name, "vesa")) continue; - if (current_card_fd >= 0) { - close(current_card_fd); - current_card_fd = -1; + if (device >= 0) { + close(device); + device = -1; } sprintf(path, "/dev/graphics/%s", entry->d_name); - current_card_fd = open(path, B_READ_WRITE); - if (current_card_fd >= 0) + device = open(path, B_READ_WRITE); + if (device >= 0) count++; } @@ -209,14 +209,14 @@ AccelerantHWInterface::_OpenGraphicsDevice(int deviceNumber) if (count < deviceNumber) { if (deviceNumber == 1) { sprintf(path, "/dev/graphics/vesa"); - current_card_fd = open(path, B_READ_WRITE); + device = open(path, B_READ_WRITE); } else { - close(current_card_fd); - current_card_fd = B_ENTRY_NOT_FOUND; + close(device); + device = B_ENTRY_NOT_FOUND; } } - return current_card_fd; + return device; } @@ -662,8 +662,18 @@ AccelerantHWInterface::GetAccelerantPath(BString &string) status_t AccelerantHWInterface::GetDriverPath(BString &string) { - // TODO: hardcoded to vesa for now. Fix me - string = "graphics/vesa"; + // TODO: this currently assumes that the accelerant's clone info + // is always the path name of its driver (that's the case for + // all of our drivers) + char path[B_PATH_NAME_LENGTH]; + get_accelerant_clone_info getCloneInfo; + getCloneInfo = (get_accelerant_clone_info)fAccelerantHook(B_GET_ACCELERANT_CLONE_INFO, NULL); + + if (getCloneInfo == NULL) + return B_NOT_SUPPORTED; + + getCloneInfo((void *)path); + string.SetTo(path); return B_OK; }