summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorzmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 22:31:06 +0000
committerzmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 22:31:06 +0000
commitba8a61c75fc97d72d94d93987eace01aaab7af8f (patch)
tree33c59f976e54b9e083b48d05b3de3cd8c23b72cd /content
parent2b03757e61c18172909e173cc71c05ec2e108246 (diff)
downloadchromium_src-ba8a61c75fc97d72d94d93987eace01aaab7af8f.zip
chromium_src-ba8a61c75fc97d72d94d93987eace01aaab7af8f.tar.gz
chromium_src-ba8a61c75fc97d72d94d93987eace01aaab7af8f.tar.bz2
Use nv contrl x extension to query nvidia driver version.
This is trying to reland the reverted CL http://codereview.chromium.org/10536232/. I added third_party/libXNVCtrl to content/gpu/DEPS. So we can do it in browser process, not wait until gpu process launches and a gl context is created. This is tested on my linux box with NVIDIA driver. We need to put more code to tell chrome (Linux/NVIDIA) that we have enough information for blacklisting, so at GPU launch time we don't need to collect GPUInfo. Will do it in a followup CL. BUG=122912 TEST=tree green R=jam@chromium.org TBR=kbr,piman Review URL: https://chromiumcodereview.appspot.com/10641006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/content_gpu.gypi5
-rw-r--r--content/gpu/DEPS1
-rw-r--r--content/gpu/gpu_info_collector_linux.cc62
3 files changed, 58 insertions, 10 deletions
diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi
index b98d991..6d9d587 100644
--- a/content/content_gpu.gypi
+++ b/content/content_gpu.gypi
@@ -90,5 +90,10 @@
},
],
}],
+ ['OS=="linux"', {
+ 'dependencies': [
+ '../third_party/libXNVCtrl/libXNVCtrl.gyp:libXNVCtrl',
+ ],
+ }],
],
}
diff --git a/content/gpu/DEPS b/content/gpu/DEPS
index 46de806..c1672fb 100644
--- a/content/gpu/DEPS
+++ b/content/gpu/DEPS
@@ -7,4 +7,5 @@ include_rules = [
"+sandbox",
"+skia",
"+third_party/libxml", # For parsing WinSAT results files.
+ "+third_party/libXNVCtrl", # For NV driver version query.
]
diff --git a/content/gpu/gpu_info_collector_linux.cc b/content/gpu/gpu_info_collector_linux.cc
index 0c53478..cdad81b 100644
--- a/content/gpu/gpu_info_collector_linux.cc
+++ b/content/gpu/gpu_info_collector_linux.cc
@@ -5,6 +5,7 @@
#include "content/gpu/gpu_info_collector.h"
#include <dlfcn.h>
+#include <X11/Xlib.h>
#include <vector>
#include "base/command_line.h"
@@ -12,10 +13,13 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
#include "base/string_piece.h"
#include "base/string_split.h"
#include "base/string_tokenizer.h"
#include "base/string_util.h"
+#include "third_party/libXNVCtrl/NVCtrl.h"
+#include "third_party/libXNVCtrl/NVCtrlLib.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
@@ -138,16 +142,16 @@ void FinalizeLibPci(PciInterface** interface) {
}
// Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
-// Return "" on failing.
+// Return empty string on failing.
std::string CollectDriverVersionATI() {
const FilePath::CharType kATIFileName[] =
FILE_PATH_LITERAL("/etc/ati/amdpcsdb.default");
FilePath ati_file_path(kATIFileName);
if (!file_util::PathExists(ati_file_path))
- return "";
+ return std::string();
std::string contents;
if (!file_util::ReadFileToString(ati_file_path, &contents))
- return "";
+ return std::string();
StringTokenizer t(contents, "\r\n");
while (t.GetNext()) {
std::string line = t.token();
@@ -162,7 +166,35 @@ std::string CollectDriverVersionATI() {
}
}
}
- return "";
+ return std::string();
+}
+
+// Use NVCtrl extention to query NV driver version.
+// Return empty string on failing.
+std::string CollectDriverVersionNVidia() {
+ Display* display = base::MessagePumpForUI::GetDefaultXDisplay();
+ if (!display) {
+ LOG(ERROR) << "XOpenDisplay failed.";
+ return std::string();
+ }
+ int event_base = 0, error_base = 0;
+ if (!XNVCTRLQueryExtension(display, &event_base, &error_base)) {
+ LOG(INFO) << "NVCtrl extension does not exits.";
+ return std::string();
+ }
+ int screen_count = ScreenCount(display);
+ for (int screen = 0; screen < screen_count; ++screen) {
+ char* buffer = NULL;
+ if (XNVCTRLIsNvScreen(display, screen) &&
+ XNVCTRLQueryStringAttribute(display, screen, 0,
+ NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
+ &buffer)) {
+ std::string driver_version(buffer);
+ XFree(buffer);
+ return driver_version;
+ }
+ }
+ return std::string();
}
const uint32 kVendorIDIntel = 0x8086;
@@ -199,12 +231,22 @@ bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) {
bool rt = CollectVideoCardInfo(gpu_info);
- if (gpu_info->gpu.vendor_id == kVendorIDAMD) {
- std::string ati_driver_version = CollectDriverVersionATI();
- if (!ati_driver_version.empty()) {
- gpu_info->driver_vendor = "ATI / AMD";
- gpu_info->driver_version = ati_driver_version;
- }
+ std::string driver_version;
+ switch (gpu_info->gpu.vendor_id) {
+ case kVendorIDAMD:
+ driver_version = CollectDriverVersionATI();
+ if (!driver_version.empty()) {
+ gpu_info->driver_vendor = "ATI / AMD";
+ gpu_info->driver_version = driver_version;
+ }
+ break;
+ case kVendorIDNVidia:
+ driver_version = CollectDriverVersionNVidia();
+ if (!driver_version.empty()) {
+ gpu_info->driver_vendor = "NVIDIA";
+ gpu_info->driver_version = driver_version;
+ }
+ break;
}
return rt;