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 #if defined(USE_LIBPCI) | |
dnicoara
2014/10/29 15:34:01
#ifdef-ed libraries should be the last included li
| |
20 #include "library_loaders/libpci.h" | 21 #include "library_loaders/libpci.h" |
22 #endif | |
21 #include "ui/gl/gl_bindings.h" | 23 #include "ui/gl/gl_bindings.h" |
22 #include "ui/gl/gl_context.h" | 24 #include "ui/gl/gl_context.h" |
23 #include "ui/gl/gl_implementation.h" | 25 #include "ui/gl/gl_implementation.h" |
24 #include "ui/gl/gl_surface.h" | 26 #include "ui/gl/gl_surface.h" |
25 #include "ui/gl/gl_switches.h" | 27 #include "ui/gl/gl_switches.h" |
26 | 28 |
27 namespace gpu { | 29 namespace gpu { |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 return std::string(); | 67 return std::string(); |
66 } | 68 } |
67 | 69 |
68 const uint32 kVendorIDIntel = 0x8086; | 70 const uint32 kVendorIDIntel = 0x8086; |
69 const uint32 kVendorIDNVidia = 0x10de; | 71 const uint32 kVendorIDNVidia = 0x10de; |
70 const uint32 kVendorIDAMD = 0x1002; | 72 const uint32 kVendorIDAMD = 0x1002; |
71 | 73 |
72 CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) { | 74 CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) { |
73 DCHECK(gpu_info); | 75 DCHECK(gpu_info); |
74 | 76 |
77 #if !defined(USE_LIBPCI) | |
78 return kCollectInfoNonFatalFailure; | |
79 #else | |
80 | |
75 if (IsPciSupported() == false) { | 81 if (IsPciSupported() == false) { |
76 VLOG(1) << "PCI bus scanning is not supported"; | 82 VLOG(1) << "PCI bus scanning is not supported"; |
77 return kCollectInfoNonFatalFailure; | 83 return kCollectInfoNonFatalFailure; |
78 } | 84 } |
79 | 85 |
80 // TODO(zmo): be more flexible about library name. | 86 // TODO(zmo): be more flexible about library name. |
81 LibPciLoader libpci_loader; | 87 LibPciLoader libpci_loader; |
82 if (!libpci_loader.Load("libpci.so.3") && | 88 if (!libpci_loader.Load("libpci.so.3") && |
83 !libpci_loader.Load("libpci.so")) { | 89 !libpci_loader.Load("libpci.so")) { |
84 VLOG(1) << "Failed to locate libpci"; | 90 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) | 143 if (gpu_info->gpu.vendor_id == kVendorIDNVidia) |
138 gpu_info->optimus = true; | 144 gpu_info->optimus = true; |
139 if (gpu_info->gpu.vendor_id == kVendorIDAMD) | 145 if (gpu_info->gpu.vendor_id == kVendorIDAMD) |
140 gpu_info->amd_switchable = true; | 146 gpu_info->amd_switchable = true; |
141 } | 147 } |
142 | 148 |
143 (libpci_loader.pci_cleanup)(access); | 149 (libpci_loader.pci_cleanup)(access); |
144 if (!primary_gpu_identified) | 150 if (!primary_gpu_identified) |
145 return kCollectInfoNonFatalFailure; | 151 return kCollectInfoNonFatalFailure; |
146 return kCollectInfoSuccess; | 152 return kCollectInfoSuccess; |
153 #endif | |
147 } | 154 } |
148 | 155 |
149 } // namespace anonymous | 156 } // namespace anonymous |
150 | 157 |
151 CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) { | 158 CollectInfoResult CollectContextGraphicsInfo(GPUInfo* gpu_info) { |
152 DCHECK(gpu_info); | 159 DCHECK(gpu_info); |
153 | 160 |
154 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); | 161 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo"); |
155 | 162 |
156 if (CommandLine::ForCurrentProcess()->HasSwitch( | 163 if (CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 gpu_info->driver_version = driver_version; | 261 gpu_info->driver_version = driver_version; |
255 return kCollectInfoSuccess; | 262 return kCollectInfoSuccess; |
256 } | 263 } |
257 | 264 |
258 void MergeGPUInfo(GPUInfo* basic_gpu_info, | 265 void MergeGPUInfo(GPUInfo* basic_gpu_info, |
259 const GPUInfo& context_gpu_info) { | 266 const GPUInfo& context_gpu_info) { |
260 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 267 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
261 } | 268 } |
262 | 269 |
263 } // namespace gpu | 270 } // namespace gpu |
OLD | NEW |