<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 4, 2016 at 8:59 AM, Lionel Landwerlin <span dir="ltr"><<a href="mailto:llandwerlin@gmail.com" target="_blank">llandwerlin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
Cc: Sirisha Gandikota <<a href="mailto:Sirisha.Gandikota@intel.com">Sirisha.Gandikota@intel.com</a>><br>
---<br>
src/intel/tools/aubinator.c | 79 +++++++++++++++++-------------<wbr>---------------<br>
1 file changed, 30 insertions(+), 49 deletions(-)<br>
<br>
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c<br>
index 9b32e5b..4e2cafa 100644<br>
--- a/src/intel/tools/aubinator.c<br>
+++ b/src/intel/tools/aubinator.c<br>
@@ -36,6 +36,8 @@<br>
#include <sys/wait.h><br>
#include <sys/mman.h><br>
<br>
+#include "util/macros.h"<br>
+<br>
#include "decoder.h"<br>
#include "intel_aub.h"<br>
#include "gen_disasm.h"<br>
@@ -1060,11 +1062,25 @@ int main(int argc, char *argv[])<br>
{<br>
struct gen_spec *spec;<br>
struct aub_file *file;<br>
- int i, pci_id = 0;<br>
+ int i;<br>
bool found_arg_gen = false, pager = true;<br>
- int gen_major, gen_minor;<br>
const char *value;<br>
char gen_file[256], gen_val[24];<br>
+ const struct {<br>
+ const char *name;<br>
+ int pci_id;<br>
+ int major;<br>
+ int minor;<br>
+ } gens[] = {<br>
+ { "ivb", 0x0166, 7, 0 }, /* Intel(R) Ivybridge Mobile GT2 */<br>
+ { "hsw", 0x0416, 7, 5 }, /* Intel(R) Haswell Mobile GT2 */<br>
+ { "byt", 0x0155, 7, 5 }, /* Intel(R) Bay Trail */<br>
+ { "bdw", 0x1616, 8, 0 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br>
+ { "chv", 0x22B3, 8, 0 }, /* Intel(R) HD Graphics (Cherryview) */<br>
+ { "skl", 0x1912, 9, 0 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */<br>
+ { "kbl", 0x591D, 9, 0 }, /* Intel(R) Kabylake GT2 */<br>
+ { "bxt", 0x0A84, 9, 0 } /* Intel(R) HD Graphics (Broxton) */<br>
+ }, *gen = NULL;<br>
<br>
if (argc == 1) {<br>
print_help(argv[0], stderr);<br>
@@ -1082,8 +1098,6 @@ int main(int argc, char *argv[])<br>
exit(EXIT_FAILURE);<br>
}<br>
found_arg_gen = true;<br>
- gen_major = 0;<br>
- gen_minor = 0;<br>
snprintf(gen_val, sizeof(gen_val), "%s", value);<br>
} else if (strcmp(argv[i], "--headers") == 0) {<br>
option_full_decode = false;<br>
@@ -1115,47 +1129,14 @@ int main(int argc, char *argv[])<br>
exit(EXIT_FAILURE);<br>
}<br>
<br>
- if (strstr(gen_val, "ivb") != NULL) {<br>
- /* Intel(R) Ivybridge Mobile GT2 */<br>
- pci_id = 0x0166;<br>
- gen_major = 7;<br>
- gen_minor = 0;<br>
- } else if (strstr(gen_val, "hsw") != NULL) {<br>
- /* Intel(R) Haswell Mobile GT2 */<br>
- pci_id = 0x0416;<br>
- gen_major = 7;<br>
- gen_minor = 5;<br>
- } else if (strstr(gen_val, "byt") != NULL) {<br>
- /* Intel(R) Bay Trail */<br>
- pci_id = 0x0155;<br>
- gen_major = 7;<br>
- gen_minor = 5;<br>
- } else if (strstr(gen_val, "bdw") != NULL) {<br>
- /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br>
- pci_id = 0x1616;<br>
- gen_major = 8;<br>
- gen_minor = 0;<br>
- } else if (strstr(gen_val, "chv") != NULL) {<br>
- /* Intel(R) HD Graphics (Cherryview) */<br>
- pci_id = 0x22B3;<br>
- gen_major = 8;<br>
- gen_minor = 0;<br>
- } else if (strstr(gen_val, "skl") != NULL) {<br>
- /* Intel(R) HD Graphics 530 (Skylake GT2) */<br>
- pci_id = 0x1912;<br>
- gen_major = 9;<br>
- gen_minor = 0;<br>
- } else if (strstr(gen_val, "kbl") != NULL) {<br>
- /* Intel(R) Kabylake GT2 */<br>
- pci_id = 0x591D;<br>
- gen_major = 9;<br>
- gen_minor = 0;<br>
- } else if (strstr(gen_val, "bxt") != NULL) {<br>
- /* Intel(R) HD Graphics (Broxton) */<br>
- pci_id = 0x0A84;<br>
- gen_major = 9;<br>
- gen_minor = 0;<br>
- } else {<br>
+ for (i = 0; i < ARRAY_SIZE(gens); i++) {<br>
+ if (!strcmp(gen_val, gens[i].name)) {<br>
+ gen = &gens[i];<br>
+ break;<br>
+ }<br>
+ }<br>
+<br>
+ if (gen == NULL) {<br>
fprintf(stderr, "can't parse gen: %s, expected ivb, byt, hsw, "<br>
"bdw, chv, skl, kbl or bxt\n", gen_val);<br>
exit(EXIT_FAILURE);<br>
@@ -1168,15 +1149,15 @@ int main(int argc, char *argv[])<br>
if (isatty(1) && pager)<br>
setup_pager();<br>
<br>
- if (gen_minor > 0) {<br>
+ if (gen->minor > 0) {<br>
snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",<br>
- gen_major, gen_minor);<br>
+ gen->major, gen->minor);<br>
} else {<br>
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen_major);<br>
+ snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen->major);<br>
}<br>
<br>
spec = gen_spec_load(gen_file);<br>
- disasm = gen_disasm_create(pci_id);<br>
+ disasm = gen_disasm_create(gen->pci_id)<wbr>;<br>
<br>
if (argv[i] == NULL) {<br>
print_help(argv[0], stderr);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>