目录
一、hal主进程数据结构
参考文章:
Android Camera原理之camera HAL底层数据结构与类总结_cameradevicestatuschange-CSDN博客
hardware/libhardware/include/hardware/camera_common.h
camera_module_t
每个硬件模块抽象出的设备必须实现,第一个成员必须是hw_module_t
typedef struct camera_module {
hw_module_t common;
int (*get_number_of_cameras)(void);
int (*get_camera_info)(int camera_id, struct camera_info *info);
int (*set_callbacks)(const camera_module_callbacks_t *callbacks);
void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops);
int (*open_legacy)(const struct hw_module_t* module, const char* id,
uint32_t halVersion, struct hw_device_t** device);
int (*set_torch_mode)(const char* camera_id, bool enabled);
int (*init)();
void* reserved[5];
} camera_module_t;
camera_module_t的camx实例在后面
hardware/libhardware/include/hardware/hardware.h
hw_module_t
typedef struct hw_module_t {
/** tag must be initialized to HARDWARE_MODULE_TAG */
uint32_t tag;
uint16_t module_api_version;
#define version_major module_api_version
uint16_t hal_api_version;
#define version_minor hal_api_version
/** Identifier of module */
const char *id;
/** Name of this module */
const char *name;
/** Author/owner/implementor of the module */
const char *author;
/** Modules methods */
struct hw_module_methods_t* methods;
/** module's dso */
void* dso;
#ifdef __LP64__
uint64_t reserved[32-7];
#else
/** padding to 128 bytes, reserved for future use */
uint32_t reserved[32-7];
#endif
} hw_module_t;
hw_module_methods_t
必须包含open函数指针,具体实现有hal层实现。
typedef struct hw_module_methods_t {
/** Open a specific device */
int (*open)(const struct hw_module_t* module, const char* id,
struct hw_device_t** device);
} hw_module_methods_t;
camera_info_t
描述camera信息,通过get_camera_info获取
typedef struct camera_info {
int facing;
int orientation;
uint32_t device_version;
const camera_metadata_t *static_camera_characteristics;
int resource_cost;
char** conflicting_devices;
size_t conflicting_devices_length;
} camera_info_t;
camera3_device_t
代表一个打开的设备,通过上面的open函数获取,第一个成员必须是hw_device_t
typedef struct camera3_device {
hw_device_t common;
camera3_device_ops_t *ops;
void *priv;
} camera3_device_t;
hw_device_t
包含close和hw_module_t
typedef struct hw_device_t {
/** tag must be initi