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

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

Issue 2263743002: Add logic to detect AMD linux driver version for both Brahma/Catalyst drivers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 28 matching lines...) Expand all
39 // This checks if a system supports PCI bus. 39 // This checks if a system supports PCI bus.
40 // We check the existence of /sys/bus/pci or /sys/bug/pci_express. 40 // We check the existence of /sys/bus/pci or /sys/bug/pci_express.
41 bool IsPciSupported() { 41 bool IsPciSupported() {
42 const base::FilePath pci_path("/sys/bus/pci/"); 42 const base::FilePath pci_path("/sys/bus/pci/");
43 const base::FilePath pcie_path("/sys/bus/pci_express/"); 43 const base::FilePath pcie_path("/sys/bus/pci_express/");
44 return (base::PathExists(pci_path) || 44 return (base::PathExists(pci_path) ||
45 base::PathExists(pcie_path)); 45 base::PathExists(pcie_path));
46 } 46 }
47 #endif // defined(USE_LIBPCI) 47 #endif // defined(USE_LIBPCI)
48 48
49 // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion". 49 // Scan /sys/module/amdgpu/version.
50 // Return empty string on failing. 50 // Return empty string on failing.
51 std::string CollectDriverVersionATI() { 51 std::string CollectDriverVersionAMDBrahma() {
52 const base::FilePath::CharType kATIFileName[] = 52 const base::FilePath ati_file_path("/sys/module/amdgpu/version");
53 FILE_PATH_LITERAL("/etc/ati/amdpcsdb.default");
54 base::FilePath ati_file_path(kATIFileName);
55 if (!base::PathExists(ati_file_path)) 53 if (!base::PathExists(ati_file_path))
56 return std::string(); 54 return std::string();
57 std::string contents; 55 std::string contents;
56 if (!base::ReadFileToString(ati_file_path, &contents))
57 return std::string();
58 size_t begin = contents.find_first_of("0123456789");
59 if (begin != std::string::npos) {
60 size_t end = contents.find_first_not_of("0123456789.", begin);
61 if (end == std::string::npos)
62 return contents.substr(begin);
63 else
64 return contents.substr(begin, end - begin);
65 }
66 return std::string();
67 }
68
69 // Scan /etc/ati/amdpcsdb.default for "ReleaseVersion".
70 // Return empty string on failing.
71 std::string CollectDriverVersionAMDCatalyst() {
72 const base::FilePath ati_file_path("/etc/ati/amdpcsdb.default");
73 if (!base::PathExists(ati_file_path))
74 return std::string();
75 std::string contents;
58 if (!base::ReadFileToString(ati_file_path, &contents)) 76 if (!base::ReadFileToString(ati_file_path, &contents))
59 return std::string(); 77 return std::string();
60 base::StringTokenizer t(contents, "\r\n"); 78 base::StringTokenizer t(contents, "\r\n");
61 while (t.GetNext()) { 79 while (t.GetNext()) {
62 std::string line = t.token(); 80 std::string line = t.token();
63 if (base::StartsWith(line, "ReleaseVersion=", 81 if (base::StartsWith(line, "ReleaseVersion=",
64 base::CompareCase::SENSITIVE)) { 82 base::CompareCase::SENSITIVE)) {
65 size_t begin = line.find_first_of("0123456789"); 83 size_t begin = line.find_first_of("0123456789");
66 if (begin != std::string::npos) { 84 if (begin != std::string::npos) {
67 size_t end = line.find_first_not_of("0123456789.", begin); 85 size_t end = line.find_first_not_of("0123456789.", begin);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 220 }
203 221
204 CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) { 222 CollectInfoResult CollectBasicGraphicsInfo(GPUInfo* gpu_info) {
205 DCHECK(gpu_info); 223 DCHECK(gpu_info);
206 224
207 CollectInfoResult result = CollectPCIVideoCardInfo(gpu_info); 225 CollectInfoResult result = CollectPCIVideoCardInfo(gpu_info);
208 226
209 std::string driver_version; 227 std::string driver_version;
210 switch (gpu_info->gpu.vendor_id) { 228 switch (gpu_info->gpu.vendor_id) {
211 case kVendorIDAMD: 229 case kVendorIDAMD:
212 driver_version = CollectDriverVersionATI(); 230 driver_version = CollectDriverVersionAMDBrahma();
213 if (!driver_version.empty()) { 231 if (!driver_version.empty()) {
214 gpu_info->driver_vendor = "ATI / AMD"; 232 gpu_info->driver_vendor = "ATI / AMD (Brahma)";
215 gpu_info->driver_version = driver_version; 233 gpu_info->driver_version = driver_version;
234 } else {
235 driver_version = CollectDriverVersionAMDCatalyst();
236 if (!driver_version.empty()) {
237 gpu_info->driver_vendor = "ATI / AMD (Catalyst)";
238 gpu_info->driver_version = driver_version;
239 }
216 } 240 }
217 break; 241 break;
218 case kVendorIDNVidia: 242 case kVendorIDNVidia:
219 driver_version = CollectDriverVersionNVidia(); 243 driver_version = CollectDriverVersionNVidia();
220 if (!driver_version.empty()) { 244 if (!driver_version.empty()) {
221 gpu_info->driver_vendor = "NVIDIA"; 245 gpu_info->driver_vendor = "NVIDIA";
222 gpu_info->driver_version = driver_version; 246 gpu_info->driver_version = driver_version;
223 } 247 }
224 break; 248 break;
225 case kVendorIDIntel: 249 case kVendorIDIntel:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 gpu_info->driver_version = driver_version; 309 gpu_info->driver_version = driver_version;
286 return kCollectInfoSuccess; 310 return kCollectInfoSuccess;
287 } 311 }
288 312
289 void MergeGPUInfo(GPUInfo* basic_gpu_info, 313 void MergeGPUInfo(GPUInfo* basic_gpu_info,
290 const GPUInfo& context_gpu_info) { 314 const GPUInfo& context_gpu_info) {
291 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); 315 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
292 } 316 }
293 317
294 } // namespace gpu 318 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698