Refine pci id detecting.
authorJunyan He <junyan.he@linux.intel.com>
Mon, 26 May 2014 15:57:32 +0000 (23:57 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 27 May 2014 02:37:06 +0000 (10:37 +0800)
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.

Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/gbe_bin_generater.cpp
src/GetGenID.sh

index 898e2f2..dce0792 100644 (file)
@@ -34,7 +34,6 @@
 #include <vector>
 #include <algorithm>
 #include <stdlib.h>
-#include <iostream>
 #include <stdio.h>
 
 #include "backend/program.h"
index f8cb0a7..ee7fe5c 100755 (executable)
@@ -1,2 +1,26 @@
 #!/bin/bash
-lspci -nn | grep "VGA.*Gen.*\[8086:" -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