blob: 7774b2b645161dcd31d3c3806cadc03fcf33eb13 [file] [log] [blame]
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H
18#define ANDROID_INCLUDE_HARDWARE_HARDWARE_H
19
20#include <stdint.h>
21#include <sys/cdefs.h>
22
Mathias Agopiana8a75162009-04-10 14:24:31 -070023#include <cutils/native_handle.h>
Iliyan Malchevc12d0e92011-04-14 20:00:02 -070024#include <system/graphics.h>
Mathias Agopiana8a75162009-04-10 14:24:31 -070025
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080026__BEGIN_DECLS
27
28/*
29 * Value for the hw_module_t.tag field
30 */
Mathias Agopiana8a75162009-04-10 14:24:31 -070031
32#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
33
34#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
35#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080036
37struct hw_module_t;
38struct hw_module_methods_t;
39struct hw_device_t;
40
41/**
42 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
43 * and the fields of this data structure must begin with hw_module_t
44 * followed by module specific information.
45 */
Mathias Agopian9d82c1a2009-08-19 11:20:55 -070046typedef struct hw_module_t {
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080047 /** tag must be initialized to HARDWARE_MODULE_TAG */
48 uint32_t tag;
49
50 /** major version number for the module */
51 uint16_t version_major;
52
53 /** minor version number of the module */
54 uint16_t version_minor;
55
56 /** Identifier of module */
57 const char *id;
58
59 /** Name of this module */
60 const char *name;
61
62 /** Author/owner/implementor of the module */
63 const char *author;
64
65 /** Modules methods */
66 struct hw_module_methods_t* methods;
Mathias Agopiana8a75162009-04-10 14:24:31 -070067
68 /** module's dso */
69 void* dso;
70
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080071 /** padding to 128 bytes, reserved for future use */
Mathias Agopiana8a75162009-04-10 14:24:31 -070072 uint32_t reserved[32-7];
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080073
Mathias Agopian9d82c1a2009-08-19 11:20:55 -070074} hw_module_t;
75
76typedef struct hw_module_methods_t {
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080077 /** Open a specific device */
78 int (*open)(const struct hw_module_t* module, const char* id,
79 struct hw_device_t** device);
Mathias Agopian9d82c1a2009-08-19 11:20:55 -070080
81} hw_module_methods_t;
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080082
83/**
84 * Every device data structure must begin with hw_device_t
85 * followed by module specific public methods and attributes.
86 */
Mathias Agopian9d82c1a2009-08-19 11:20:55 -070087typedef struct hw_device_t {
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080088 /** tag must be initialized to HARDWARE_DEVICE_TAG */
89 uint32_t tag;
90
91 /** version number for hw_device_t */
92 uint32_t version;
93
94 /** reference to the module this device belongs to */
95 struct hw_module_t* module;
96
97 /** padding reserved for future use */
98 uint32_t reserved[12];
99
100 /** Close this device */
101 int (*close)(struct hw_device_t* device);
Mathias Agopian9d82c1a2009-08-19 11:20:55 -0700102
103} hw_device_t;
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800104
105/**
Mathias Agopiana8a75162009-04-10 14:24:31 -0700106 * Name of the hal_module_info
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800107 */
108#define HAL_MODULE_INFO_SYM HMI
109
110/**
111 * Name of the hal_module_info as a string
112 */
113#define HAL_MODULE_INFO_SYM_AS_STR "HMI"
114
115/**
116 * Get the module info associated with a module by id.
Dima Zavin54921de2011-04-18 10:55:37 -0700117 *
118 * @return: 0 == success, <0 == error and *module == NULL
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800119 */
120int hw_get_module(const char *id, const struct hw_module_t **module);
121
Dima Zavin54921de2011-04-18 10:55:37 -0700122/**
123 * Get the module info associated with a module instance by class 'class_id'
124 * and instance 'inst'.
125 *
126 * Some modules types necessitate multiple instances. For example audio supports
127 * multiple concurrent interfaces and thus 'audio' is the module class
128 * and 'primary' or 'a2dp' are module interfaces. This implies that the files
129 * providing these modules would be named audio.primary.<variant>.so and
130 * audio.a2dp.<variant>.so
131 *
132 * @return: 0 == success, <0 == error and *module == NULL
133 */
134int hw_get_module_by_class(const char *class_id, const char *inst,
135 const struct hw_module_t **module);
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800136
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800137__END_DECLS
138
139#endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */