blob: 4d34852c742ddbab222e794e2fb00d24000a9f89 [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>
24
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080025__BEGIN_DECLS
26
27/*
28 * Value for the hw_module_t.tag field
29 */
Mathias Agopiana8a75162009-04-10 14:24:31 -070030
31#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D))
32
33#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T')
34#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T')
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080035
36struct hw_module_t;
37struct hw_module_methods_t;
38struct hw_device_t;
39
40/**
41 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
42 * and the fields of this data structure must begin with hw_module_t
43 * followed by module specific information.
44 */
45struct hw_module_t {
46 /** tag must be initialized to HARDWARE_MODULE_TAG */
47 uint32_t tag;
48
49 /** major version number for the module */
50 uint16_t version_major;
51
52 /** minor version number of the module */
53 uint16_t version_minor;
54
55 /** Identifier of module */
56 const char *id;
57
58 /** Name of this module */
59 const char *name;
60
61 /** Author/owner/implementor of the module */
62 const char *author;
63
64 /** Modules methods */
65 struct hw_module_methods_t* methods;
Mathias Agopiana8a75162009-04-10 14:24:31 -070066
67 /** module's dso */
68 void* dso;
69
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080070 /** padding to 128 bytes, reserved for future use */
Mathias Agopiana8a75162009-04-10 14:24:31 -070071 uint32_t reserved[32-7];
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -080072};
73
74struct hw_module_methods_t {
75 /** Open a specific device */
76 int (*open)(const struct hw_module_t* module, const char* id,
77 struct hw_device_t** device);
78};
79
80/**
81 * Every device data structure must begin with hw_device_t
82 * followed by module specific public methods and attributes.
83 */
84struct hw_device_t {
85 /** tag must be initialized to HARDWARE_DEVICE_TAG */
86 uint32_t tag;
87
88 /** version number for hw_device_t */
89 uint32_t version;
90
91 /** reference to the module this device belongs to */
92 struct hw_module_t* module;
93
94 /** padding reserved for future use */
95 uint32_t reserved[12];
96
97 /** Close this device */
98 int (*close)(struct hw_device_t* device);
99};
100
101/**
Mathias Agopiana8a75162009-04-10 14:24:31 -0700102 * Name of the hal_module_info
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800103 */
104#define HAL_MODULE_INFO_SYM HMI
105
106/**
107 * Name of the hal_module_info as a string
108 */
109#define HAL_MODULE_INFO_SYM_AS_STR "HMI"
110
111/**
112 * Get the module info associated with a module by id.
113 * @return: 0 == success, <0 == error and *pHmi == NULL
114 */
115int hw_get_module(const char *id, const struct hw_module_t **module);
116
117
118/**
119 * pixel format definitions
120 */
121
122enum {
123 HAL_PIXEL_FORMAT_RGBA_8888 = 1,
Mathias Agopian7d512e32009-08-07 20:55:37 -0700124 HAL_PIXEL_FORMAT_RGBX_8888 = 2,
125 HAL_PIXEL_FORMAT_RGB_888 = 3,
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800126 HAL_PIXEL_FORMAT_RGB_565 = 4,
127 HAL_PIXEL_FORMAT_BGRA_8888 = 5,
128 HAL_PIXEL_FORMAT_RGBA_5551 = 6,
129 HAL_PIXEL_FORMAT_RGBA_4444 = 7,
130 HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10,
131 HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x11,
132 HAL_PIXEL_FORMAT_YCbCr_422_P = 0x12,
133 HAL_PIXEL_FORMAT_YCbCr_420_P = 0x13,
134 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14,
Benny Wong49b02f72009-07-07 11:43:52 -0500135 HAL_PIXEL_FORMAT_YCbCr_420_I = 0x15,
136 HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x16,
137 HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x17
The Android Open Source Projectf53ebec2009-03-03 19:32:14 -0800138};
139
140
141/**
142 * Transformation definitions
143 */
144
145enum {
146 /* flip source image horizontally */
147 HAL_TRANSFORM_FLIP_H = 0x01,
148 /* flip source image vertically */
149 HAL_TRANSFORM_FLIP_V = 0x02,
150 /* rotate source image 90 degres */
151 HAL_TRANSFORM_ROT_90 = 0x04,
152 /* rotate source image 180 degres */
153 HAL_TRANSFORM_ROT_180 = 0x03,
154 /* rotate source image 270 degres */
155 HAL_TRANSFORM_ROT_270 = 0x07,
156};
157
158__END_DECLS
159
160#endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */