├── Android.mk ├── README.md ├── get_offsets.c └── struct.py /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES := get_offsets.c 6 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../camera/QCamera2/stack/common 7 | 8 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 9 | LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 10 | 11 | LOCAL_MODULE_TAGS := optional 12 | LOCAL_MODULE := get_offsets 13 | LOCAL_MODULE_CLASS := EXECUTABLES 14 | 15 | LOCAL_CFLAGS := -Wall -Werror 16 | 17 | LOCAL_32_BIT_ONLY := true 18 | 19 | include $(BUILD_EXECUTABLE) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Code that can help to debug metadata_data_t struct used by qualcomm camera code. 2 | 3 | It is located in QCamera2/stack/common/cam_intf.h 4 | 5 | Main idea is to compare output from functions get_pointer_of() and get_size_of() from binary libmmcamera2_mct.so, (liboemcamera.so for older devices) with values defined in oss header. 6 | 7 | To get started, you hav to make list of fields of metadata_data_t using special macro PRINT(), like 8 | 9 | ``` 10 | PRINT(CAM_INTF_META_FACE_DETECTION, pMetadata); 11 | PRINT(CAM_INTF_META_FACE_RECOG, pMetadata); 12 | ``` 13 | 14 | Next build it and copy get_offsets binary to /system/vendor/lib on your device where libmmcamera2_mct.so located. 15 | 16 | Run it and it will produce output like this 17 | 18 | ``` 19 | BLOB: CAM_INTF_META_AUTOFOCUS_DATA index=19 pointer=8784 size=56 20 | OSS : CAM_INTF_META_AUTOFOCUS_DATA index=19 pointer=8784 size=56 21 | FIXME!!! 22 | BLOB: CAM_INTF_META_CDS_DATA index=203 pointer=310378496 size=0 23 | OSS : CAM_INTF_META_CDS_DATA index=203 pointer=8840 size=68 24 | BLOB: CAM_INTF_PARM_UPDATE_DEBUG_LEVEL index=175 pointer=8908 size=4 25 | OSS : CAM_INTF_PARM_UPDATE_DEBUG_LEVEL index=175 pointer=8908 size=4 26 | ``` 27 | 28 | Current code contains keys used on kuntao device. 29 | 30 | * BLOB means values found in libmmcamera2_mct.so 31 | * OSS means values from your current cam_intf.h 32 | * FIXME means fields that different by offset or by size. Some BLOB values will be size=0 and big pointer, it means this field not used in blob (but thats *not* mean you have to remove it from oss HAL). 33 | -------------------------------------------------------------------------------- /get_offsets.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Camera 5 | #include 6 | 7 | #define CAM_LIB_MCT "libmmcamera2_mct.so" 8 | #define CAM_LIB_OEM "liboemcamera.so" 9 | 10 | #define PRINT(PARAM_ID, table_ptr) \ 11 | blob_pointer = (char*)(get_pointer_of(PARAM_ID, table_ptr)) - (char*)(table_ptr); \ 12 | oss_pointer = (char*)(POINTER_OF_META(PARAM_ID, table_ptr)) - (char*)(table_ptr); \ 13 | blob_size = get_size_of(PARAM_ID); \ 14 | oss_size = SIZE_OF_PARAM(PARAM_ID, table_ptr); \ 15 | if ((blob_pointer != oss_pointer) || (blob_size != oss_size)) printf("FIXME!!!\n"); \ 16 | printf("BLOB: %s index=%d pointer=%d size=%d\n", #PARAM_ID, PARAM_ID, blob_pointer, blob_size); \ 17 | printf("OSS : %s index=%d pointer=%d size=%d\n", #PARAM_ID, PARAM_ID, oss_pointer, oss_size); 18 | 19 | typedef void* (*get_pointer_of_t)(cam_intf_parm_type_t, metadata_buffer_t*); 20 | typedef uint32_t (*get_size_of_t)(cam_intf_parm_type_t); 21 | 22 | void* find_library_handle() { 23 | void* handle; 24 | handle = dlopen(CAM_LIB_MCT, RTLD_LAZY); 25 | if (handle) { 26 | return handle; 27 | } 28 | 29 | handle = dlopen(CAM_LIB_OEM, RTLD_LAZY); 30 | if (handle) { 31 | return handle; 32 | } 33 | 34 | return NULL; 35 | } 36 | 37 | int main() { 38 | void* handle; 39 | get_pointer_of_t get_pointer_of; 40 | get_size_of_t get_size_of; 41 | metadata_buffer_t* pMetadata = malloc(sizeof(metadata_buffer_t)); 42 | 43 | handle = find_library_handle(); 44 | if (!handle) { 45 | fprintf(stderr, "%s\n", dlerror()); 46 | return 1; 47 | } 48 | 49 | get_pointer_of = (get_pointer_of_t)dlsym(handle, "get_pointer_of"); 50 | if (!get_pointer_of) { 51 | fprintf(stderr, "%s\n", dlerror()); 52 | return 1; 53 | } 54 | 55 | get_size_of = (get_size_of_t)dlsym(handle, "get_size_of"); 56 | if (!get_size_of) { 57 | fprintf(stderr, "%s\n", dlerror()); 58 | return 1; 59 | } 60 | 61 | int blob_pointer = 0; 62 | int oss_pointer = 0; 63 | int blob_size = 0; 64 | int oss_size = 0; 65 | 66 | /* INCLUDE() macros from metadata_data_t go after this */ 67 | 68 | dlclose(handle); 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /struct.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | with open('../camera/QCamera2/stack/common/cam_intf.h', 'r') as f: 4 | data = f.read() 5 | f.closed 6 | 7 | start = data.find(' INCLUDE(CAM_INTF_META_HISTOGRAM') 8 | end = data.find('} metadata_data_t;') 9 | data = data[start:end] 10 | metadata = data.split("\n") 11 | 12 | metalist = list() 13 | 14 | for line in metadata: 15 | if (line.startswith(' INCLUDE')): 16 | foo = line.split(',') 17 | foo[0] = foo[0].replace('INCLUDE', 'PRINT') 18 | 19 | metalist.append(foo[0] + ", pMetadata);") 20 | 21 | with open('list.txt', 'w') as f: 22 | for item in metalist: 23 | f.write("%s\n" % item) 24 | f.closed 25 | --------------------------------------------------------------------------------