OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "gpu/config/gpu_info_collector_linux.h" | 5 #include "gpu/config/gpu_info_collector_linux.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "base/strings/string_tokenizer.h" | 17 #include "base/strings/string_tokenizer.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "gpu/config/gpu_info_collector.h" | 19 #include "gpu/config/gpu_info_collector.h" |
20 #include "library_loaders/libpci.h" | |
21 #include "ui/gl/gl_bindings.h" | 20 #include "ui/gl/gl_bindings.h" |
22 #include "ui/gl/gl_context.h" | 21 #include "ui/gl/gl_context.h" |
23 #include "ui/gl/gl_implementation.h" | 22 #include "ui/gl/gl_implementation.h" |
24 #include "ui/gl/gl_surface.h" | 23 #include "ui/gl/gl_surface.h" |
25 #include "ui/gl/gl_switches.h" | 24 #include "ui/gl/gl_switches.h" |
26 | 25 |
| 26 #if defined(USE_LIBPCI) |
| 27 #include "library_loaders/libpci.h" |
| 28 #endif |
| 29 |
27 namespace gpu { | 30 namespace gpu { |
28 | 31 |
29 namespace { | 32 namespace { |
30 | 33 |
31 // This checks if a system supports PCI bus. | 34 // This checks if a system supports PCI bus. |
32 // We check the existence of /sys/bus/pci or /sys/bug/pci_express. | 35 // We check the existence of /sys/bus/pci or /sys/bug/pci_express. |
33 bool IsPciSupported() { | 36 bool IsPciSupported() { |
34 const base::FilePath pci_path("/sys/bus/pci/"); | 37 const base::FilePath pci_path("/sys/bus/pci/"); |
35 const base::FilePath pcie_path("/sys/bus/pci_express/"); | 38 const base::FilePath pcie_path("/sys/bus/pci_express/"); |
36 return (base::PathExists(pci_path) || | 39 return (base::PathExists(pci_path) || |
(...skipping 28 matching lines...) Expand all Loading... |
65 return std::string(); | 68 return std::string(); |
66 } | 69 } |
67 | 70 |
68 const uint32 kVendorIDIntel = 0x8086; | 71 const uint32 kVendorIDIntel = 0x8086; |
69 const uint32 kVendorIDNVidia = 0x10de; | 72 const uint32 kVendorIDNVidia = 0x10de; |
70 const uint32 kVendorIDAMD = 0x1002; | 73 const uint32 kVendorIDAMD = 0x1002; |
71 | 74 |
72 CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) { | 75 CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) { |
73 DCHECK(gpu_info); | 76 DCHECK(gpu_info); |
74 | 77 |
| 78 #if !defined(USE_LIBPCI) |
| 79 return kCollectInfoNonFatalFailure; |
| 80 #else |
| 81 |
75 if (IsPciSupported() == false) { | 82 if (IsPciSupported() == false) { |
76 VLOG(1) << "PCI bus scanning is not supported"; | 83 VLOG(1) << "PCI bus scanning is not supported"; |
77 return kCollectInfoNonFatalFailure; | 84 return kCollectInfoNonFatalFailure; |
78 } | 85 } |
79 | 86 |
80 // TODO(zmo): be more flexible about library name. | 87 // TODO(zmo): be more flexible about library name. |
81 LibPciLoader libpci_loader; | 88 LibPciLoader libpci_loader; |
82 if (!libpci_loader.Load("libpci.so.3") && | 89 if (!libpci_loader.Load("libpci.so.3") && |
83 !libpci_loader.Load("libpci.so")) { | 90 !libpci_loader.Load("libpci.so")) { |
84 VLOG(1) << "Failed to locate libpci"; | 91 VLOG(1) << "Failed to locate libpci"; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (gpu_info->gpu.vendor_id == kVendorIDNVidia) | 144 if (gpu_info->gpu.vendor_id == kVendorIDNVidia) |
138 gpu_info->optimus = true; | 145 gpu_info->optimus = true; |
139 if (gpu_info->gpu.vendor_id == kVendorIDAMD) | 146 if (gpu_info->gpu.vendor_id == kVendorIDAMD) |
140 gpu_info->amd_switchable = true; | 147 gpu_info->amd_switchable = true; |
141 } | 148 } |
142 | 149 |
143 (libpci_loader.pci_cleanup)(access); | 150 (libpci_loader.pci_cleanup)(access); |
144 if (!primary_gpu_identified) | 151 if (!primary_gpu_identified) |
145 return kCollectInfoNonFatalFailure; | 152 return kCollectInfoNonFatalFailure; |
146 return kCollectInfoSuccess; | 153 return kCollectInfoSuccess; |
| 154 #endif |
147 } | 155 } |
148 | 156 |
149 } // namespace anonymous | 157 } // namespace anonymous |
150 | 158 |
151 CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) { | 159 CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) { |
152 DCHECK(gpu_info); | 160 DCHECK(gpu_info); |
153 | 161 |
154 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); | 162 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); |
155 | 163 |
156 if (CommandLine::ForCurrentProcess()->HasSwitch( | 164 if (CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 gpu_info->driver_version = driver_version; | 262 gpu_info->driver_version = driver_version; |
255 return kCollectInfoSuccess; | 263 return kCollectInfoSuccess; |
256 } | 264 } |
257 | 265 |
258 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 266 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
259 const GPUInfo& context_gpu_info) { | 267 const GPUInfo& context_gpu_info) { |
260 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 268 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
261 } | 269 } |
262 | 270 |
263 } // namespace gpu | 271 } // namespace gpu |
OLD | NEW |