Added support for Android. Changes include fixes for compilation issues related to Android using an older version of GCC compiler (ver 4.3.3) while the latest version of intel-gpu-tools confirms to GCC ver 4.5.2 (C99 standard functions), using functions like getline(). Fixed such functions, header dependencies for android and added an Android.mk file. signed-off-by: Sateesh Kavuri <sateesh.kavuri at intel.com> --- Android.mk | 528 ++++++++++++++++++++++++++++++++++++++++++++ lib/intel_drm.c | 6 +- lib/intel_mmio.c | 4 + lib/intel_pci.c | 4 + tools/intel_decode.c | 10 + tools/intel_dump_decode.c | 14 +- tools/intel_error_decode.c | 14 ++ tools/intel_gpu_top.c | 6 +- tools/intel_reg_write.c | 2 + 9 files changed, 584 insertions(+), 4 deletions(-) create mode 100644 Android.mk diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..0fc04cd --- /dev/null +++ b/Android.mk @@ -0,0 +1,528 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_reg_write.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_reg_map.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + +LOCAL_MODULE := intel_reg_write +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_reg_read.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_reg_map.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_reg_read +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_disable_clock_gating.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_disable_clock_gating +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_audio_dump.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_audio_dump +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_backlight.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_backlight +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_bios_dumper.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_bios_dumper +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_bios_reader.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_bios_reader +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_error_decode.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h \ + lib/instdone.h \ + lib/instdone.c \ + tools/intel_decode.h \ + tools/intel_decode.c \ + lib/intel_drm.c + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_error_decode +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_gpu_top.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h \ + lib/instdone.h \ + lib/instdone.c \ + lib/intel_reg_map.c + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_gpu_top +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_gpu_time.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_gpu_time +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_gtt.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 + +LOCAL_MODULE := intel_gtt +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_stepping.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_stepping +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_reg_dumper.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_reg_dumper +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/intel_reg_snapshot.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 + +LOCAL_MODULE := intel_reg_snapshot +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + tools/forcewaked.c \ + lib/intel_pci.c \ + lib/intel_gpu_tools.h \ + tools/intel_reg.h \ + lib/intel_batchbuffer.h \ + lib/intel_batchbuffer.c \ + lib/intel_mmio.c \ + tools/intel_chipset.h \ + lib/intel_reg_map.c + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := forcewaked +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess \ + libdrm \ + libdrm_intel + +include $(BUILD_EXECUTABLE) + +#================ +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + lib/intel_gpu_tools.h \ + tools/intel_reg_checker.c \ + lib/intel_pci.c \ + lib/intel_mmio.c + + +LOCAL_C_INCLUDES += \ + $(LOCAL_PATH)/lib \ + $(TOPDIR)hardware/intel/libdrm/include/drm \ + $(TOPDIR)hardware/intel/libdrm/intel \ + $(LOCAL_PATH)/../libpciaccess/include/ + +LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +LOCAL_CFLAGS += -DANDROID + + +LOCAL_MODULE := intel_reg_checker +LOCAL_MODULE_TAGS := optional + +LOCAL_SHARED_LIBRARIES := libpciaccess + +include $(BUILD_EXECUTABLE) + diff --git a/lib/intel_drm.c b/lib/intel_drm.c index f8eca7d..1f51856 100644 --- a/lib/intel_drm.c +++ b/lib/intel_drm.c @@ -25,7 +25,7 @@ * */ -#include "config.h" +#include "../config.h" #include <unistd.h> #include <stdlib.h> @@ -35,7 +35,11 @@ #include <err.h> #include <assert.h> #include <sys/ioctl.h> +#ifdef ANDROID +#include <fcntl.h> +#else #include <sys/fcntl.h> +#endif #include <sys/stat.h> #include <sys/mman.h> #ifdef HAVE_STRUCT_SYSINFO_TOTALRAM diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c index da68bdf..2020833 100644 --- a/lib/intel_mmio.c +++ b/lib/intel_mmio.c @@ -38,7 +38,11 @@ #include <err.h> #include <assert.h> #include <sys/ioctl.h> +#ifdef ANDROID +#include <fcntl.h> +#else #include <sys/fcntl.h> +#endif #include <sys/stat.h> #include <sys/mman.h> diff --git a/lib/intel_pci.c b/lib/intel_pci.c index 7bc7466..98889ca 100644 --- a/lib/intel_pci.c +++ b/lib/intel_pci.c @@ -33,7 +33,11 @@ #include <err.h> #include <assert.h> #include <sys/ioctl.h> +#ifdef ANDROID +#include <fcntl.h> +#else #include <sys/fcntl.h> +#endif #include <sys/stat.h> #include <sys/mman.h> diff --git a/tools/intel_decode.c b/tools/intel_decode.c index 344578b..5ed508f 100644 --- a/tools/intel_decode.c +++ b/tools/intel_decode.c @@ -198,7 +198,12 @@ decode_mi(uint32_t *data, int count, uint32_t hw_offset, int *failures) if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) { instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name); + #ifdef ANDROID + int i; + for (i = 1; i < len; i++) { + #else for (int i = 1; i < len; i++) { + #endif if (i >= count) BUFFER_FAIL(count, len, opcodes_mi[opcode].name); instr_out(data, hw_offset, i, "dword %d\n", i); @@ -1164,7 +1169,12 @@ decode_3d_1d(uint32_t *data, int count, break; case 2: instr_out(data, hw_offset, i, "S2: texcoord formats: "); + #ifdef ANDROID + int tex_num; + for (tex_num = 0; tex_num < 8; tex_num++) { + #else for (int tex_num = 0; tex_num < 8; tex_num++) { + #endif switch((data[i]>>tex_num*4)&0xf) { case 0: fprintf(out, "%i=2D ", tex_num); break; case 1: fprintf(out, "%i=3D ", tex_num); break; diff --git a/tools/intel_dump_decode.c b/tools/intel_dump_decode.c index 26d57f5..57c1261 100644 --- a/tools/intel_dump_decode.c +++ b/tools/intel_dump_decode.c @@ -67,6 +67,10 @@ read_data_file(uint32_t devid, const char * filename) FILE *file; uint32_t *data = NULL; int data_size = 0, count = 0, line_number = 0, matched; + #ifdef ANDROID + char line[1024]; + size_t line_size = 1024; + #else char *line = NULL; size_t line_size; uint32_t offset, value; @@ -82,9 +86,15 @@ read_data_file(uint32_t devid, const char * filename) filename, strerror (errno)); exit (1); } - +#ifdef ANDROID + while (fgets (line, line_size, file) != 0) { + line[strcspn(line, "\n")] = '\0'; + if (line[0] == '\0') continue; +#else while (getline (&line, &line_size, file) > 0) { - line_number++; +#endif + + line_number++; matched = sscanf (line, "%08x : %08x", &offset, &value); if (matched != 2) { diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c index 6ffaefe..c9c74ba 100644 --- a/tools/intel_error_decode.c +++ b/tools/intel_error_decode.c @@ -280,15 +280,27 @@ read_data_file (FILE *file) uint32_t *data = NULL; long long unsigned fence; int data_size = 0, count = 0, line_number = 0, matched; +#ifdef ANDROID + char line[1024]; + size_t line_size = 1024; +#else char *line = NULL; size_t line_size; +#endif uint32_t offset, value; uint32_t gtt_offset = 0, new_gtt_offset; char *buffer_type[2] = { "ringbuffer", "batchbuffer" }; char *ring_name = NULL; int is_batch = 1; +#ifdef ANDROID + while (fgets (line, line_size, file) != 0) { + line[strcspn(line, "\n")] = '\0'; + if (line[0] == '\0') continue; +#else while (getline (&line, &line_size, file) > 0) { +#endif + char *dashes; line_number++; @@ -404,7 +416,9 @@ read_data_file (FILE *file) } free (data); +#ifndef ANDROID free (line); +#endif free (ring_name); } diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c index 033ba53..b9d1ce9 100644 --- a/tools/intel_gpu_top.c +++ b/tools/intel_gpu_top.c @@ -27,7 +27,7 @@ * */ -#include "config.h" +#include "../config.h" #include <unistd.h> #include <stdlib.h> @@ -602,10 +602,14 @@ int main(int argc, char **argv) /* Limit the number of lines printed to the terminal height so the * most important info (at the top) will stay on screen. */ unsigned short int max_lines = -1; +#ifndef ANDROID struct winsize ws; if (ioctl(0, TIOCGWINSZ, &ws) != -1) max_lines = ws.ws_row - 6; /* exclude header lines */ if (max_lines >= num_instdone_bits) + // FIXME: ioctl-types.h still does not exist in Android. Hard code + // the max_lines value for now (winsize is part of ioctl-types.h +#endif max_lines = num_instdone_bits; t2 = gettime(); diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c index c8af9bb..81bceef 100644 --- a/tools/intel_reg_write.c +++ b/tools/intel_reg_write.c @@ -25,6 +25,8 @@ * */ +#include "../config.h" + #include <unistd.h> #include <stdlib.h> #include <stdio.h> -- 1.7.4.1