diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-22 21:34:59 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-22 21:34:59 +0000 |
commit | 3225aeb02d64058e7d30ffcfda69a68002e2af53 (patch) | |
tree | c7e4dddb309f24167f3e63a61decbe9952ba952c /content | |
parent | ba253a9411c29744d47a50cb80f0b65dda4df36c (diff) | |
download | chromium_src-3225aeb02d64058e7d30ffcfda69a68002e2af53.zip chromium_src-3225aeb02d64058e7d30ffcfda69a68002e2af53.tar.gz chromium_src-3225aeb02d64058e7d30ffcfda69a68002e2af53.tar.bz2 |
Collect ATI driver version through scanning /etc/ati.
This will enable us to blacklist only older ATI drivers on linux in the future.
BUG=none
TEST=about:gpu shows driver version in linux using ATI cards.
Review URL: http://codereview.chromium.org/6708055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79040 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/gpu/gpu_info_collector_linux.cc | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/content/gpu/gpu_info_collector_linux.cc b/content/gpu/gpu_info_collector_linux.cc index 28e0d9b..5f187fa 100644 --- a/content/gpu/gpu_info_collector_linux.cc +++ b/content/gpu/gpu_info_collector_linux.cc @@ -15,6 +15,7 @@ #include "base/scoped_ptr.h" #include "base/string_piece.h" #include "base/string_split.h" +#include "base/string_tokenizer.h" #include "base/string_util.h" namespace { @@ -132,6 +133,34 @@ void FinalizeLibPci(PciInterface** interface) { *interface = NULL; } +// Scan /etc/ati/amdpcsdb.default for "ReleaseVersion". +// Return "" on failing. +std::string CollectDriverVersionATI() { + const FilePath::CharType kATIFileName[] = + FILE_PATH_LITERAL("/etc/ati/amdpcsdb.default"); + FilePath ati_file_path(kATIFileName); + if (!file_util::PathExists(ati_file_path)) + return ""; + std::string contents; + if (!file_util::ReadFileToString(ati_file_path, &contents)) + return ""; + StringTokenizer t(contents, "\r\n"); + while (t.GetNext()) { + std::string line = t.token(); + if (StartsWithASCII(line, "ReleaseVersion=", true)) { + size_t begin = line.find_first_of("0123456789"); + if (begin != std::string::npos) { + size_t end = line.find_first_not_of("0123456789.", begin); + if (end == std::string::npos) + return line.substr(begin); + else + return line.substr(begin, end - begin); + } + } + } + return ""; +} + } // namespace anonymous namespace gpu_info_collector { @@ -154,8 +183,13 @@ bool CollectPreliminaryGraphicsInfo(GPUInfo* gpu_info) { if (!CollectVideoCardInfo(gpu_info)) rt = false; - // TODO(zmo): if vendor is ATI, consider passing /etc/ati/amdpcsdb.default - // for driver information. + if (gpu_info->vendor_id == 0x1002) { // ATI + std::string ati_driver_version = CollectDriverVersionATI(); + if (ati_driver_version != "") { + gpu_info->driver_vendor = "ATI / AMD"; + gpu_info->driver_version = ati_driver_version; + } + } return rt; } |