1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "base/logging.h"
8 #include "gpu/config/gpu_info_collector_linux.h"
9 #include "third_party/libXNVCtrl/NVCtrl.h"
10 #include "third_party/libXNVCtrl/NVCtrlLib.h"
11 #include "ui/gfx/x/x11_types.h"
15 // Use NVCtrl extention to query NV driver version.
16 // Return empty string on failing.
17 std::string
CollectDriverVersionNVidia() {
18 Display
* display
= gfx::GetXDisplay();
20 LOG(ERROR
) << "XOpenDisplay failed.";
23 int event_base
= 0, error_base
= 0;
24 if (!XNVCTRLQueryExtension(display
, &event_base
, &error_base
)) {
25 VLOG(1) << "NVCtrl extension does not exist.";
28 int screen_count
= ScreenCount(display
);
29 for (int screen
= 0; screen
< screen_count
; ++screen
) {
31 if (XNVCTRLIsNvScreen(display
, screen
) &&
32 XNVCTRLQueryStringAttribute(display
, screen
, 0,
33 NV_CTRL_STRING_NVIDIA_DRIVER_VERSION
,
35 std::string
driver_version(buffer
);
37 return driver_version
;