diff options
author | JP Abgrall <jpa@google.com> | 2012-10-03 20:16:57 -0700 |
---|---|---|
committer | JP Abgrall <jpa@google.com> | 2012-10-03 20:16:57 -0700 |
commit | 33ce91b37062fa63af192f5643de93f3beebe854 (patch) | |
tree | ba6a03c7954a32ce23b00c6d46cd3d524f4d7007 /libsensors_iio/software/core/HAL/linux/mlos_linux.c | |
parent | 64ca18f95225d0a86f7ccfd1d21c23971b9f77ae (diff) | |
download | android_hardware_invensense-33ce91b37062fa63af192f5643de93f3beebe854.tar.gz android_hardware_invensense-33ce91b37062fa63af192f5643de93f3beebe854.tar.bz2 android_hardware_invensense-33ce91b37062fa63af192f5643de93f3beebe854.zip |
MotionApps 5.1.1 release, with MA 5.1.0 for further merge review.cm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1.2cm-10.1.1cm-10.1.0-RC5cm-10.1.0-RC4cm-10.1.0-RC3cm-10.1.0-RC2cm-10.1.0-RC1cm-10.1.0cm-10.1-M3cm-10.1-M2cm-10.1-M1mr1.1-stagingcm-10.1
1. Removed all #ifdef in HAL's member APIs.
2. Added necessary comments as reference.
3. Made changes for coding style, optimization and so on per prior comments.
4. Now raw/calibrated gyroscope sensors could co-exist
Default sensor would be calibrated gyroscope sensor
for getDefaultSensor() call in Android.
* Correctly handle onPower()/masterEnable().
* Use the support functions for reading/writing sysfs.
1 line instead of 9 all over the place.
* Fix return code for {read,write}_sysfs_int():
was > 0 in case of failure instead of < 0.
Bug: 7211625
Change-Id: Ib49dab8ca0f48f45a2838de72f4f8ac011d0e68f
Diffstat (limited to 'libsensors_iio/software/core/HAL/linux/mlos_linux.c')
-rw-r--r-- | libsensors_iio/software/core/HAL/linux/mlos_linux.c | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/libsensors_iio/software/core/HAL/linux/mlos_linux.c b/libsensors_iio/software/core/HAL/linux/mlos_linux.c deleted file mode 100644 index 75f062e..0000000 --- a/libsensors_iio/software/core/HAL/linux/mlos_linux.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - $License: - Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. - $ - */ -/******************************************************************************* - * - * $Id: mlos_linux.c 5629 2011-06-11 03:13:08Z mcaramello $ - * - *******************************************************************************/ - -/** - * @defgroup MLOS - * @brief OS Interface. - * - * @{ - * @file mlos.c - * @brief OS Interface. -**/ - -/* ------------- */ -/* - Includes. - */ -/* ------------- */ - -#include <sys/time.h> -#include <unistd.h> -#include <pthread.h> -#include <stdlib.h> - -#include "stdint_invensense.h" - -#include "mlos.h" -#include <errno.h> - - -/* -------------- */ -/* - Functions. - */ -/* -------------- */ - -/** - * @brief Allocate space - * @param numBytes number of bytes - * @return pointer to allocated space -**/ -void *inv_malloc(unsigned int numBytes) -{ - // Allocate space. - void *allocPtr = malloc(numBytes); - return allocPtr; -} - - -/** - * @brief Free allocated space - * @param ptr pointer to space to deallocate - * @return error code. -**/ -inv_error_t inv_free(void *ptr) -{ - // Deallocate space. - free(ptr); - - return INV_SUCCESS; -} - - -/** - * @brief Mutex create function - * @param mutex pointer to mutex handle - * @return error code. - */ -inv_error_t inv_create_mutex(HANDLE *mutex) -{ - int res; - pthread_mutex_t *pm = malloc(sizeof(pthread_mutex_t)); - if(pm == NULL) - return INV_ERROR; - - res = pthread_mutex_init(pm, NULL); - if(res == -1) { - free(pm); - return INV_ERROR_OS_CREATE_FAILED; - } - - *mutex = (HANDLE)pm; - - return INV_SUCCESS; -} - - -/** - * @brief Mutex lock function - * @param mutex Mutex handle - * @return error code. - */ -inv_error_t inv_lock_mutex(HANDLE mutex) -{ - int res; - pthread_mutex_t *pm = (pthread_mutex_t*)mutex; - - res = pthread_mutex_lock(pm); - if(res == -1) - return INV_ERROR_OS_LOCK_FAILED; - - return INV_SUCCESS; -} - - -/** - * @brief Mutex unlock function - * @param mutex mutex handle - * @return error code. -**/ -inv_error_t inv_unlock_mutex(HANDLE mutex) -{ - int res; - pthread_mutex_t *pm = (pthread_mutex_t*)mutex; - - res = pthread_mutex_unlock(pm); - if(res == -1) - return INV_ERROR_OS_LOCK_FAILED; - - return INV_SUCCESS; -} - - -/** - * @brief open file - * @param filename name of the file to open. - * @return error code. - */ -FILE *inv_fopen(char *filename) -{ - FILE *fp = fopen(filename,"r"); - return fp; -} - - -/** - * @brief close the file. - * @param fp handle to file to close. - * @return error code. - */ -void inv_fclose(FILE *fp) -{ - fclose(fp); -} - -/** - * @brief Close Handle - * @param handle handle to the resource. - * @return Zero if success, an error code otherwise. - */ -inv_error_t inv_destroy_mutex(HANDLE handle) -{ - int error; - pthread_mutex_t *pm = (pthread_mutex_t*)handle; - error = pthread_mutex_destroy(pm); - if (error) { - return errno; - } - free((void*) handle); - - return INV_SUCCESS;} - - -/** - * @brief Sleep function. - */ -void inv_sleep(int mSecs) -{ - usleep(mSecs*1000); -} - - -/** - * @brief get system's internal tick count. - * Used for time reference. - * @return current tick count. - */ -unsigned long inv_get_tick_count() -{ - struct timeval tv; - - if (gettimeofday(&tv, NULL) !=0) - return 0; - - return (long)((tv.tv_sec * 1000000LL + tv.tv_usec) / 1000LL); -} - - /**********************/ - /** @} */ /* defgroup */ -/**********************/ - |