• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
23 __BEGIN_DECLS
24 
25 /*
26  * Value for the hw_module_t.tag field
27  */
28 #define HARDWARE_MODULE_TAG 'HWMT'
29 #define HARDWARE_DEVICE_TAG 'HWDT'
30 
31 struct hw_module_t;
32 struct hw_module_methods_t;
33 struct hw_device_t;
34 
35 /**
36  * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
37  * and the fields of this data structure must begin with hw_module_t
38  * followed by module specific information.
39  */
40 struct hw_module_t {
41     /** tag must be initialized to HARDWARE_MODULE_TAG */
42     uint32_t tag;
43 
44     /** major version number for the module */
45     uint16_t version_major;
46 
47     /** minor version number of the module */
48     uint16_t version_minor;
49 
50     /** Identifier of module */
51     const char *id;
52 
53     /** Name of this module */
54     const char *name;
55 
56     /** Author/owner/implementor of the module */
57     const char *author;
58 
59     /** Modules methods */
60     struct hw_module_methods_t* methods;
61 
62     /** padding to 128 bytes, reserved for future use */
63     uint32_t reserved[32-6];
64 };
65 
66 struct hw_module_methods_t {
67     /** Open a specific device */
68     int (*open)(const struct hw_module_t* module, const char* id,
69             struct hw_device_t** device);
70 };
71 
72 /**
73  * Every device data structure must begin with hw_device_t
74  * followed by module specific public methods and attributes.
75  */
76 struct hw_device_t {
77     /** tag must be initialized to HARDWARE_DEVICE_TAG */
78     uint32_t tag;
79 
80     /** version number for hw_device_t */
81     uint32_t version;
82 
83     /** reference to the module this device belongs to */
84     struct hw_module_t* module;
85 
86     /** padding reserved for future use */
87     uint32_t reserved[12];
88 
89     /** Close this device */
90     int (*close)(struct hw_device_t* device);
91 };
92 
93 /**
94  * Name of the hal_module_info
95  */
96 #define HAL_MODULE_INFO_SYM         HMI
97 
98 /**
99  * Name of the hal_module_info as a string
100  */
101 #define HAL_MODULE_INFO_SYM_AS_STR  "HMI"
102 
103 /**
104  * Get the module info associated with a module by id.
105  * @return: 0 == success, <0 == error and *pHmi == NULL
106  */
107 int hw_get_module(const char *id, const struct hw_module_t **module);
108 
109 
110 /**
111  * pixel format definitions
112  */
113 
114 enum {
115     HAL_PIXEL_FORMAT_RGBA_8888    = 1,
116     HAL_PIXEL_FORMAT_RGB_565      = 4,
117     HAL_PIXEL_FORMAT_BGRA_8888    = 5,
118     HAL_PIXEL_FORMAT_RGBA_5551    = 6,
119     HAL_PIXEL_FORMAT_RGBA_4444    = 7,
120     HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10,
121     HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x11,
122     HAL_PIXEL_FORMAT_YCbCr_422_P  = 0x12,
123     HAL_PIXEL_FORMAT_YCbCr_420_P  = 0x13,
124     HAL_PIXEL_FORMAT_YCbCr_422_I  = 0x14,
125     HAL_PIXEL_FORMAT_YCbCr_420_I  = 0x15
126 };
127 
128 
129 /**
130  * Transformation definitions
131  */
132 
133 enum {
134     /* flip source image horizontally */
135     HAL_TRANSFORM_FLIP_H    = 0x01,
136     /* flip source image vertically */
137     HAL_TRANSFORM_FLIP_V    = 0x02,
138     /* rotate source image 90 degres */
139     HAL_TRANSFORM_ROT_90    = 0x04,
140     /* rotate source image 180 degres */
141     HAL_TRANSFORM_ROT_180   = 0x03,
142     /* rotate source image 270 degres */
143     HAL_TRANSFORM_ROT_270   = 0x07,
144 };
145 
146 __END_DECLS
147 
148 #endif  /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */
149