#!/bin/bash
INVENTORY=$(mktemp lspci.XXXXXXXX)

lspci > $INVENTORY

NVIDIA_GPU=$(cat $INVENTORY | grep -i nvidia | wc -l)
XILINX_FPGA=$(cat $INVENTORY | grep "Processing accelerators: Xilinx Corporation Device" | wc -l)
INTEL_A10_FPGA=$(cat $INVENTORY | grep "Processing accelerators: Intel Corporation Device" | wc -l)
AMD_GPU=$(cat $INVENTORY | grep "Display controller: Advanced Micro Devices, Inc. \[AMD/ATI\]" | wc -l)

cat << EOF
{
	"xilinx_fpga" : $XILINX_FPGA,
	"nvidia_gpu" : $NVIDIA_GPU,
	"amd_gpu" : $AMD_GPU,
	"intel_a10_fpga" : $INTEL_A10_FPGA
}
EOF

rm -f $INVENTORY
