Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1782)

Side by Side Diff: content/gpu/gpu_info_collector_linux.cc

Issue 10536232: Use nv contrl x extension to query nvidia driver version. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_gpu.gypi ('k') | third_party/libXNVCtrl/libXNVCtrl.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/gpu/gpu_info_collector.h" 5 #include "content/gpu/gpu_info_collector.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <X11/Xlib.h>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/debug/trace_event.h" 12 #include "base/debug/trace_event.h"
12 #include "base/file_util.h" 13 #include "base/file_util.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop.h"
15 #include "base/string_piece.h" 17 #include "base/string_piece.h"
16 #include "base/string_split.h" 18 #include "base/string_split.h"
17 #include "base/string_tokenizer.h" 19 #include "base/string_tokenizer.h"
18 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "content/public/browser/browser_thread.h"
22 #include "third_party/libXNVCtrl/NVCtrl.h"
23 #include "third_party/libXNVCtrl/NVCtrlLib.h"
19 #include "ui/gl/gl_bindings.h" 24 #include "ui/gl/gl_bindings.h"
20 #include "ui/gl/gl_context.h" 25 #include "ui/gl/gl_context.h"
21 #include "ui/gl/gl_implementation.h" 26 #include "ui/gl/gl_implementation.h"
22 #include "ui/gl/gl_surface.h" 27 #include "ui/gl/gl_surface.h"
23 #include "ui/gl/gl_switches.h" 28 #include "ui/gl/gl_switches.h"
24 29
25 namespace { 30 namespace {
26 31
27 // PciDevice and PciAccess are defined to access libpci functions. Their 32 // PciDevice and PciAccess are defined to access libpci functions. Their
28 // members match the corresponding structures defined by libpci in size up to 33 // members match the corresponding structures defined by libpci in size up to
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (end == std::string::npos) 163 if (end == std::string::npos)
159 return line.substr(begin); 164 return line.substr(begin);
160 else 165 else
161 return line.substr(begin, end - begin); 166 return line.substr(begin, end - begin);
162 } 167 }
163 } 168 }
164 } 169 }
165 return ""; 170 return "";
166 } 171 }
167 172
173 // Use NVCtrl extention to query NV driver version.
174 std::string CollectDriverVersionNVidia() {
175 Display* display = base::MessagePumpForUI::GetDefaultXDisplay();
176 if (!display) {
177 LOG(ERROR) << "XOpenDisplay failed.";
178 return "";
179 }
180 int event_base = 0, error_base = 0;
181 if (!XNVCTRLQueryExtension(display, &event_base, &error_base)) {
182 LOG(INFO) << "NVCtrl extension does not exits.";
183 return "";
184 }
185 int screen_count = ScreenCount(display);
186 for (int screen = 0; screen < screen_count; ++screen) {
187 char* buffer = NULL;
188 if (XNVCTRLIsNvScreen(display, screen) &&
189 XNVCTRLQueryStringAttribute(display, screen, 0,
190 NV_CTRL_STRING_NVIDIA_DRIVER_VERSION,
191 &buffer)) {
192 std::string driver_version(buffer);
193 XFree(buffer);
194 return driver_version;
195 }
196 }
197 return "";
198 }
199
168 const uint32 kVendorIDIntel = 0x8086; 200 const uint32 kVendorIDIntel = 0x8086;
169 const uint32 kVendorIDNVidia = 0x10de; 201 const uint32 kVendorIDNVidia = 0x10de;
170 const uint32 kVendorIDAMD = 0x1002; 202 const uint32 kVendorIDAMD = 0x1002;
171 203
172 } // namespace anonymous 204 } // namespace anonymous
173 205
174 namespace gpu_info_collector { 206 namespace gpu_info_collector {
175 207
176 bool CollectGraphicsInfo(content::GPUInfo* gpu_info) { 208 bool CollectGraphicsInfo(content::GPUInfo* gpu_info) {
177 DCHECK(gpu_info); 209 DCHECK(gpu_info);
(...skipping 11 matching lines...) Expand all
189 } 221 }
190 222
191 gpu_info->finalized = true; 223 gpu_info->finalized = true;
192 bool rt = CollectGraphicsInfoGL(gpu_info); 224 bool rt = CollectGraphicsInfoGL(gpu_info);
193 225
194 return rt; 226 return rt;
195 } 227 }
196 228
197 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) { 229 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) {
198 DCHECK(gpu_info); 230 DCHECK(gpu_info);
231 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
199 232
200 bool rt = CollectVideoCardInfo(gpu_info); 233 bool rt = CollectVideoCardInfo(gpu_info);
201 234
202 if (gpu_info->gpu.vendor_id == kVendorIDAMD) { 235 std::string driver_version;
203 std::string ati_driver_version = CollectDriverVersionATI(); 236 switch (gpu_info->gpu.vendor_id) {
204 if (!ati_driver_version.empty()) { 237 case kVendorIDAMD:
205 gpu_info->driver_vendor = "ATI / AMD"; 238 driver_version = CollectDriverVersionATI();
206 gpu_info->driver_version = ati_driver_version; 239 if (!driver_version.empty()) {
207 } 240 gpu_info->driver_vendor = "ATI / AMD";
241 gpu_info->driver_version = driver_version;
242 }
243 break;
244 case kVendorIDNVidia:
245 driver_version = CollectDriverVersionNVidia();
246 if (!driver_version.empty()) {
247 gpu_info->driver_vendor = "NVIDIA";
248 gpu_info->driver_version = driver_version;
249 }
250 break;
208 } 251 }
209 252
210 return rt; 253 return rt;
211 } 254 }
212 255
213 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) { 256 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) {
214 DCHECK(gpu_info); 257 DCHECK(gpu_info);
215 258
216 if (IsPciSupported() == false) { 259 if (IsPciSupported() == false) {
217 VLOG(1) << "PCI bus scanning is not supported"; 260 VLOG(1) << "PCI bus scanning is not supported";
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return false; 364 return false;
322 if (pos != std::string::npos) 365 if (pos != std::string::npos)
323 driver_version = driver_version.substr(0, pos); 366 driver_version = driver_version.substr(0, pos);
324 367
325 gpu_info->driver_vendor = pieces[1]; 368 gpu_info->driver_vendor = pieces[1];
326 gpu_info->driver_version = driver_version; 369 gpu_info->driver_version = driver_version;
327 return true; 370 return true;
328 } 371 }
329 372
330 } // namespace gpu_info_collector 373 } // namespace gpu_info_collector
OLDNEW
« no previous file with comments | « content/content_gpu.gypi ('k') | third_party/libXNVCtrl/libXNVCtrl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698