1ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/* 2ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Copyright (C) 2013 The Android Open Source Project 3ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 4ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Licensed under the Apache License, Version 2.0 (the "License"); 5ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * you may not use this file except in compliance with the License. 6ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * You may obtain a copy of the License at 7ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 8ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * http://www.apache.org/licenses/LICENSE-2.0 9ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * 10ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * Unless required by applicable law or agreed to in writing, software 11ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * distributed under the License is distributed on an "AS IS" BASIS, 12ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * See the License for the specific language governing permissions and 14ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson * limitations under the License. 15ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson */ 16ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 17ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <errno.h> 18ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 19ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <hardware/memtrack.h> 20ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 21ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "memtrack_msm.h" 22ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 23ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonint msm_memtrack_init(const struct memtrack_module *module) 24ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson{ 25a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson if(!module) 26a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson return -1; 27ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return 0; 28ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 29ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 30ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonint msm_memtrack_get_memory(const struct memtrack_module *module, 31ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson pid_t pid, 32ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson int type, 33ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson struct memtrack_record *records, 34ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson size_t *num_records) 35ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson{ 36a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson if(!module) 37a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson return -1; 38ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson if (type == MEMTRACK_TYPE_GL || type == MEMTRACK_TYPE_GRAPHICS) { 39ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return kgsl_memtrack_get_memory(pid, type, records, num_records); 40ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson } 41ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 42ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson return -EINVAL; 43ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} 44ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 45ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonstatic struct hw_module_methods_t memtrack_module_methods = { 46ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson .open = NULL, 47ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson}; 48ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 49ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonstruct memtrack_module HAL_MODULE_INFO_SYM = { 50ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson common: { 51ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson tag: HARDWARE_MODULE_TAG, 52ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson module_api_version: MEMTRACK_MODULE_API_VERSION_0_1, 53ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson hal_api_version: HARDWARE_HAL_API_VERSION, 54ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson id: MEMTRACK_HARDWARE_MODULE_ID, 55ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson name: "MSM Memory Tracker HAL", 56ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson author: "The Android Open Source Project", 57ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson methods: &memtrack_module_methods, 58ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson }, 59ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 60ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson init: msm_memtrack_init, 61ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson getMemory: msm_memtrack_get_memory, 62ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson}; 63ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson 64