From: Junyan He <[email protected]>

1. Some platforms do not have key word "Gen" or "Graphic" when run the
   lspci command. So we failed to get the pci id in such cases.
   We now just use the 8086 key word and get the sub pci id, and compare
   it to all the gen known gen pci ids. This can be safe in all platforms.
2. When the pci id has a-f hex digit, the pci id in gbe_bin_generater is
   wrong. Fix it.

Signed-off-by: Junyan He <[email protected]>
Signed-off-by: Zhigang Gong <[email protected]>
---
 backend/src/gbe_bin_generater.cpp |    7 +++++--
 src/GetGenID.sh                   |   26 +++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/backend/src/gbe_bin_generater.cpp 
b/backend/src/gbe_bin_generater.cpp
index 50020b5..898e2f2 100644
--- a/backend/src/gbe_bin_generater.cpp
+++ b/backend/src/gbe_bin_generater.cpp
@@ -34,6 +34,7 @@
 #include <vector>
 #include <algorithm>
 #include <stdlib.h>
+#include <iostream>
 #include <stdio.h>
 
 #include "backend/program.h"
@@ -46,7 +47,7 @@ using namespace std;
 #define FILE_BUILD_FAILED 3
 #define FILE_SERIALIZATION_FAILED 4
 
-static int gen_pci_id = 0;
+static uint32_t gen_pci_id = 0;
 
 class program_build_instance {
 
@@ -296,7 +297,9 @@ int main (int argc, const char **argv)
                 return 1;
             }
 
-            gen_pci_id = (s[0] - '0') << 12 | (s[1] - '0') << 8 | (s[2] - '0') 
<< 4 | (s[3] - '0');
+            std::stringstream str(s);
+            str >> std::hex >> gen_pci_id;
+
             used_index[optind-1] = 1;
             // We must set the image base index here, as we invoke the backend 
in a non-standard way.
             gbe_set_image_base_index(3);
diff --git a/src/GetGenID.sh b/src/GetGenID.sh
index 3114bd8..ee7fe5c 100755
--- a/src/GetGenID.sh
+++ b/src/GetGenID.sh
@@ -1,2 +1,26 @@
 #!/bin/bash
-lspci -nn | grep "Gen .* Graphics" -i  | grep "\[8086:.*\]" -o | awk -F : 
'{print $2}' | awk -F ] '{print $1}'
+genpciid=(0152 0162 0156 0166 015a 0f31 0402 0412 0422 040a 041a 042a 0406 
0416 0426 0c02 0c12 0c22 0c0a 0c1a 0c2a 0c06 0c16 0c26 0a02 0a12 0a22 0a0a 0a1a 
0a2a 0a06 0a16 0a26 0d02 0d12 0d22 0d0a 0d1a 0d2a 0d06 0d16 0d26)
+pciid=($(lspci -nn | grep "\[8086:.*\]" -o | awk -F : '{print $2}' | awk -F ] 
'{print $1}'))
+n=${#pciid[*]}
+i=0
+m=${#genpciid[*]}
+j=0
+while [ $i -lt $n ]
+do
+    id1=${pciid[$i]}
+    let j=0
+
+    while [ $j -lt $m ]
+    do
+       id2=${genpciid[$j]}
+
+       if [ ${id1} == ${id2} ]
+       then
+           echo ${id1}
+           exit 0
+       fi
+       let j=j+1
+    done
+
+    let i=i+1
+done
-- 
1.7.9.5



_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to