Merge "Ensure we get a default sample rate for "query" cases in open_input_device()." into nyc-dev
am: 86df5ad096
* commit '86df5ad096224060eb5275e6b7c4a1d5552210ee':
Ensure we get a default sample rate for "query" cases in open_input_device().
Change-Id: I484e88a6b8da002b40f2769e3d869434f0b9efb2
diff --git a/include/hardware/gralloc.h b/include/hardware/gralloc.h
index ef86f90..779915c 100644
--- a/include/hardware/gralloc.h
+++ b/include/hardware/gralloc.h
@@ -379,6 +379,38 @@
return device->common.close(&device->common);
}
+/**
+ * map_usage_to_memtrack should be called after allocating a gralloc buffer.
+ *
+ * @param usage - it is the flag used when alloc function is called.
+ *
+ * This function maps the gralloc usage flags to appropriate memtrack bucket.
+ * GrallocHAL implementers and users should make an additional ION_IOCTL_TAG
+ * call using the memtrack tag returned by this function. This will help the
+ * in-kernel memtack to categorize the memory allocated by different processes
+ * according to their usage.
+ *
+ */
+static inline const char* map_usage_to_memtrack(uint32_t usage) {
+ usage &= GRALLOC_USAGE_ALLOC_MASK;
+
+ if ((usage & GRALLOC_USAGE_HW_CAMERA_WRITE) != 0) {
+ return "camera";
+ } else if ((usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) != 0 ||
+ (usage & GRALLOC_USAGE_EXTERNAL_DISP) != 0) {
+ return "video";
+ } else if ((usage & GRALLOC_USAGE_HW_RENDER) != 0 ||
+ (usage & GRALLOC_USAGE_HW_TEXTURE) != 0) {
+ return "gl";
+ } else if ((usage & GRALLOC_USAGE_HW_CAMERA_READ) != 0) {
+ return "camera";
+ } else if ((usage & GRALLOC_USAGE_SW_READ_MASK) != 0 ||
+ (usage & GRALLOC_USAGE_SW_WRITE_MASK) != 0) {
+ return "cpu";
+ }
+ return "graphics";
+}
+
__END_DECLS
#endif // ANDROID_GRALLOC_INTERFACE_H