michael@0: /* michael@0: * Copyright (C) 2008 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H michael@0: #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include michael@0: #include michael@0: michael@0: __BEGIN_DECLS michael@0: michael@0: /* michael@0: * Value for the hw_module_t.tag field michael@0: */ michael@0: michael@0: #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) michael@0: michael@0: #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') michael@0: #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') michael@0: michael@0: struct hw_module_t; michael@0: struct hw_module_methods_t; michael@0: struct hw_device_t; michael@0: michael@0: /** michael@0: * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM michael@0: * and the fields of this data structure must begin with hw_module_t michael@0: * followed by module specific information. michael@0: */ michael@0: typedef struct hw_module_t { michael@0: /** tag must be initialized to HARDWARE_MODULE_TAG */ michael@0: uint32_t tag; michael@0: michael@0: /** major version number for the module */ michael@0: uint16_t version_major; michael@0: michael@0: /** minor version number of the module */ michael@0: uint16_t version_minor; michael@0: michael@0: /** Identifier of module */ michael@0: const char *id; michael@0: michael@0: /** Name of this module */ michael@0: const char *name; michael@0: michael@0: /** Author/owner/implementor of the module */ michael@0: const char *author; michael@0: michael@0: /** Modules methods */ michael@0: struct hw_module_methods_t* methods; michael@0: michael@0: /** module's dso */ michael@0: void* dso; michael@0: michael@0: /** padding to 128 bytes, reserved for future use */ michael@0: uint32_t reserved[32-7]; michael@0: michael@0: } hw_module_t; michael@0: michael@0: typedef struct hw_module_methods_t { michael@0: /** Open a specific device */ michael@0: int (*open)(const struct hw_module_t* module, const char* id, michael@0: struct hw_device_t** device); michael@0: michael@0: } hw_module_methods_t; michael@0: michael@0: /** michael@0: * Every device data structure must begin with hw_device_t michael@0: * followed by module specific public methods and attributes. michael@0: */ michael@0: typedef struct hw_device_t { michael@0: /** tag must be initialized to HARDWARE_DEVICE_TAG */ michael@0: uint32_t tag; michael@0: michael@0: /** version number for hw_device_t */ michael@0: uint32_t version; michael@0: michael@0: /** reference to the module this device belongs to */ michael@0: struct hw_module_t* module; michael@0: michael@0: /** padding reserved for future use */ michael@0: uint32_t reserved[12]; michael@0: michael@0: /** Close this device */ michael@0: int (*close)(struct hw_device_t* device); michael@0: michael@0: } hw_device_t; michael@0: michael@0: /** michael@0: * Name of the hal_module_info michael@0: */ michael@0: #define HAL_MODULE_INFO_SYM HMI michael@0: michael@0: /** michael@0: * Name of the hal_module_info as a string michael@0: */ michael@0: #define HAL_MODULE_INFO_SYM_AS_STR "HMI" michael@0: michael@0: /** michael@0: * Get the module info associated with a module by id. michael@0: * michael@0: * @return: 0 == success, <0 == error and *module == NULL michael@0: */ michael@0: int hw_get_module(const char *id, const struct hw_module_t **module); michael@0: michael@0: /** michael@0: * Get the module info associated with a module instance by class 'class_id' michael@0: * and instance 'inst'. michael@0: * michael@0: * Some modules types necessitate multiple instances. For example audio supports michael@0: * multiple concurrent interfaces and thus 'audio' is the module class michael@0: * and 'primary' or 'a2dp' are module interfaces. This implies that the files michael@0: * providing these modules would be named audio.primary..so and michael@0: * audio.a2dp..so michael@0: * michael@0: * @return: 0 == success, <0 == error and *module == NULL michael@0: */ michael@0: int hw_get_module_by_class(const char *class_id, const char *inst, michael@0: const struct hw_module_t **module); michael@0: michael@0: __END_DECLS michael@0: michael@0: #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */