Skip to content

Commit

Permalink
Merge remote-tracking branch 'caf/LA.BR.1.3.7_rb1.6' into lineage-15.…
Browse files Browse the repository at this point in the history
…0-caf-8952

Change-Id: Ib4bc3c514ee13463ebcd2e7d3783d0d2b0a3c5cc
  • Loading branch information
intervigilium committed Jan 1, 2018
2 parents f31a219 + aeaf0ce commit 79324b0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ else
endif

display-hals := libgralloc libcopybit libmemtrack libqservice libqdutils
display-hals += hdmi_cec
display-hals += hdmi_cec include

ifeq ($(TARGET_USES_SDM), true)
sdm-libs := sdm/libs
Expand Down
21 changes: 14 additions & 7 deletions common.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#Common headers
common_includes := $(call project-path-for,qcom-display)/libgralloc
common_includes += $(call project-path-for,qcom-display)/liboverlay
common_includes += $(call project-path-for,qcom-display)/libcopybit
common_includes += $(call project-path-for,qcom-display)/libqdutils
common_includes += $(call project-path-for,qcom-display)/libhwcomposer
common_includes += $(call project-path-for,qcom-display)/libhdmi
common_includes += $(call project-path-for,qcom-display)/libqservice
display_top := $(call my-dir)

#Common headers
common_includes := $(display_top)/libgralloc
common_includes += $(display_top)/liboverlay
common_includes += $(display_top)/libcopybit
common_includes += $(display_top)/libqdutils
common_includes += $(display_top)/libhwcomposer
common_includes += $(display_top)/libhdmi
common_includes += $(display_top)/libqservice
common_includes += $(display_top)/include

common_header_export_path := qcom/display

Expand Down Expand Up @@ -36,6 +40,9 @@ ifeq ($(TARGET_USES_QCOM_BSP),true)
# Enable QCOM Display features
common_flags += -DQTI_BSP
endif

common_flags += -isystem $(TARGET_OUT_HEADERS)/qcom/display

ifneq ($(call is-platform-sdk-version-at-least,18),true)
common_flags += -DANDROID_JELLYBEAN_MR1=1
endif
Expand Down
15 changes: 15 additions & 0 deletions include/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
LOCAL_PATH:= $(call my-dir)
include $(LOCAL_PATH)/../common.mk
include $(CLEAR_VARS)
#TODO move all exported headers to this directory
LOCAL_MODULE := display_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := $(display_top)/libcopybit \
$(display_top)/libqdutils \
$(display_top)/libqservice \

ifeq ($(TARGET_USES_GRALLOC1), true)
LOCAL_EXPORT_C_INCLUDE_DIRS += $(display_top)/libgralloc1
else
LOCAL_EXPORT_C_INCLUDE_DIRS += $(display_top)/libgralloc
endif
include $(BUILD_HEADER_LIBRARY)
29 changes: 10 additions & 19 deletions libmemtrack/kgsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
FILE *fp;
char line[1024];
char tmp[128];
bool is_surfaceflinger = false;
size_t accounted_size = 0;
size_t unaccounted_size = 0;

Expand All @@ -59,16 +58,6 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
return 0;
}

snprintf(tmp, sizeof(tmp), "/proc/%d/cmdline", pid);
fp = fopen(tmp, "r");
if (fp != NULL) {
if (fgets(line, sizeof(line), fp)) {
if (strcmp(line, "/system/bin/surfaceflinger") == 0)
is_surfaceflinger = true;
}
fclose(fp);
}

memcpy(records, record_templates,
sizeof(struct memtrack_record) * allocated_records);

Expand All @@ -87,19 +76,20 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
char line_type[7];
char flags[8];
char line_usage[19];
int ret;
int ret, egl_surface_count = 0, egl_image_count = 0;

if (fgets(line, sizeof(line), fp) == NULL) {
break;
}

/* Format:
* gpuaddr useraddr size id flags type usage sglen mapsize
* 545ba000 545ba000 4096 1 -----pY gpumem arraybuffer 1 4096
* gpuaddr useraddr size id flags type usage sglen mapsize eglsrf eglimg
* 545ba000 545ba000 4096 1 -----pY gpumem arraybuffer 1 4096 0 0
*/
ret = sscanf(line, "%*x %*x %lu %*d %7s %6s %18s %*d %lu\n",
&size, flags, line_type, line_usage, &mapsize);
if (ret != 5) {
ret = sscanf(line, "%*x %*x %lu %*d %7s %6s %18s %*d %lu %6d %6d\n",
&size, flags, line_type, line_usage, &mapsize,
&egl_surface_count, &egl_image_count);
if (ret != 7) {
continue;
}

Expand All @@ -124,9 +114,10 @@ int kgsl_memtrack_get_memory(pid_t pid, enum memtrack_type type,
} else
unaccounted_size += size;
} else if (type == MEMTRACK_TYPE_GRAPHICS && strcmp(line_type, "ion") == 0) {
if ( !(is_surfaceflinger == false && strcmp(line_usage, "egl_surface") == 0)) {
if (strcmp(line_usage, "egl_surface") == 0)
unaccounted_size += size;
}
else if (egl_surface_count == 0)
unaccounted_size += size / (egl_image_count ? egl_image_count : 1);
}
}

Expand Down

0 comments on commit 79324b0

Please sign in to comment.