2 # Copyright (c) 2016 Broadcom
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 from __future__
import (
24 absolute_import
, division
, print_function
, unicode_literals
34 class DriverClassifier(object):
38 self
.collect_driver_info()
39 self
.find_categories()
42 def collect_driver_info(self
):
43 """Method for collecting the GL driver renderer string.
45 Currently only glxinfo is used.
49 self
.collect_glxinfo()
52 def collect_glxinfo(self
):
53 """Calls glxinfo and parses the output to find the GL driver
55 vendor/renderer strings.
59 output
= subprocess
.check_output(
60 ['glxinfo'], stderr
=subprocess
.STDOUT
).decode('utf-8')
62 if e
.errno
not in [errno
.ENOENT
, errno
.EACCES
]:
65 except subprocess
.CalledProcessError
:
68 for line
in output
.splitlines():
69 m
= re
.match('OpenGL renderer string: (.*)', line
)
71 self
.renderer
= m
.group(1)
75 def find_categories(self
):
76 """Parses the vendor/renderer strings to decide what categories
78 the driver falls under.
80 if self
.renderer
.startswith(('Mesa ', 'Gallium ')):
81 self
.categories
.append('mesa')
83 m
= re
.match('.* VC4(.*)', self
.renderer
)
85 self
.categories
.append('vc4')
86 m
= re
.match(' V3D ([0-9])+\.([0-9])+', m
.group(1))
88 self
.categories
.append('vc4-{}.{}'.format(m
.group(1),
91 m
= re
.match('Mesa DRI R200 ', self
.renderer
)
93 self
.categories
.append('r200')
95 m
= re
.match('Mesa DRI Intel[^ ]* (.*)', self
.renderer
)
102 '.*[GQ]4[35]': 'g4x',
104 'Sandybridge': 'snb',
110 'HD Graphics .* \(Skylake': 'skl',
112 '.*Cherryview': 'chv',
116 for chip
, abbrev
in i965_chipdict
.items():
117 m
= re
.match(chip
, tail
)
119 self
.categories
.append('i965')
120 self
.categories
.append('i965-{}'.format(abbrev
))
123 self
.categories
.reverse()