消除编译错误.

Signed-off-by: rick.chan <chenyang@autoai.com>
This commit is contained in:
rick.chan 2020-06-10 15:35:57 +08:00
parent 798d67b956
commit b8c62c06de
3 changed files with 24 additions and 18 deletions

View File

@ -6,7 +6,9 @@ LOCAL_MODULE := miccom.default
LOCAL_MODULE_RELATIVE_PATH := $(TARGET_OUT_SHARED_LIBRARIIES)/hw
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_VENDOR_MODULE := true
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := libhardware libcutils libutils
LOCAL_SRC_FILES := miccom.c
include $(BUILD_SHARED_LIBRARY)

View File

@ -10,31 +10,34 @@
*/
#define LOG_TAG "MiccomStub"
#include <hard/hardware.h>
#include <hardware/hardware.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <cutils/log.h>
#include <cutils/atomic.h>
#include <string.h>
#include <stdlib.h>
#include "miccom.h"
#define DEVICE_NAME "/dev/miccom"
#define MODULE_NAME "Miccom"
#define MODULE_AUTHOR "cy187lion@sina.com"
#define MODULE_AUTHOR "chenyang@auotai.com"
static int miccom_device_open(const struct hw_module_t* module, const char* name, struct hw_device_t** device);
static int miccom_device_close(struct hw_device_t* device);
static int miccom_set_reg(struct miccom_device_t* dev, char reg, unsigned char num);
static int miccom_get_reg(struct miccom_device_t* dev, char* reg, unsigned char num);
static struct hw_modult_methods_t miccom_module_methods = {
static struct hw_module_methods_t miccom_module_methods = {
.open = miccom_device_open
};
struct miccom_module_t HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
.version_major: 1,
.version_minor: 0,
.version_major = 1,
.version_minor = 0,
.id = MICCOM_HARDWARE_MODULE_ID,
.name = MODULE_NAME,
.author = MODULE_AUTHOR,
@ -48,26 +51,26 @@ static int miccom_device_open(const struct hw_module_t* module, const char* name
dev = (struct hw_device_t*)malloc(sizeof(*dev));
if(!dev) {
LOGE("Miccom stub: failed to alloc space.");
ALOGE("Miccom stub: failed to alloc space.");
return -EFAULT;
}
memset(dev, 0, sizeof(*dev));
dev->common.tag = HARDWARE_DEVICE_TAG;
dev->common.version = 0;
dev->common.module = const_cast<hw_module_t *>(module);
dev->common.module = (hw_module_t*)(module);
dev->common.close = miccom_device_close;
dev->set_reg = miccom_set_reg;
dev->get_reg = miccom_get_reg;
if(dev->fd = open(DEVICE_NAME, O_RDWR) == -1) {
LOGE("Miccom stub: failed to open "DEVICE_NAME" -- %s.", strerror(errno));
ALOGE("Miccom stub: failed to open "DEVICE_NAME" -- %s.", strerror(errno));
free(dev);
return -EFAULT;
}
*device = &(dev->common);
LOGI("Miccom stub: Open "DEVICE_NAME" successfully.");
ALOGI("Miccom stub: Open "DEVICE_NAME" successfully.");
return 0;
}
@ -85,16 +88,17 @@ static int miccom_device_close(struct hw_device_t* device)
static int miccom_set_reg(struct miccom_device_t* dev, char reg, unsigned char num)
{
LOGI("Miccom stub: set value %d to device reg.", reg);
// write(dev->fd, &reg, num);
ALOGI("Miccom stub: set value %d to device reg.", reg);
write(dev->fd, &reg, num);
return 0;
}
static int miccom_get_reg(struct miccom_device_t* dev, char* reg, unsigned char num)
{
if(!reg) {
LOGE("Miccom stub: error reg pointer.");
ALOGE("Miccom stub: error reg pointer.");
}
// read(dev->fd, reg, num);
LOGI("Miccom stub: get value %d from device reg.", *reg);
read(dev->fd, reg, num);
ALOGI("Miccom stub: get value %d from device reg.", *reg);
return 0;
}

View File

@ -18,7 +18,7 @@ __BEGIN_DECLS
#define MICCOM_HARDWARE_MODULE_ID "miccom"
struct miccom_module_t {
struct hw_modult_t common;
struct hw_module_t common;
};
struct miccom_device_t {
@ -26,8 +26,8 @@ struct miccom_device_t {
int fd;
int (*set_reg)(struct miccom_device_t* dev, char reg, unsigned char num);
int (*get_reg)(struct miccom_device_t* dev, char* reg, unsigned char num);
}
};
_END_DECLS
__END_DECLS
#endif // _ANDROID_DEMO_HAL_DRIVER_INTERFACE_H_