Rom Lemarchand | 1b22d07 | 2013-11-22 14:59:54 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | #include <cstddef> |
| 18 | #include <system/window.h> |
| 19 | #include <hardware/hardware.h> |
| 20 | #include <hardware/sensors.h> |
| 21 | #include <hardware/fb.h> |
| 22 | #include <hardware/hwcomposer.h> |
| 23 | #include <hardware/gralloc.h> |
| 24 | #include <hardware/consumerir.h> |
| 25 | #include <hardware/camera_common.h> |
| 26 | #include <hardware/camera3.h> |
| 27 | |
| 28 | //Ideally this would print type.member instead we need to rely on the line number from the output |
| 29 | template <size_t actual, size_t expected> void check_member(void) { |
| 30 | static_assert(actual == expected, ""); |
| 31 | } |
| 32 | |
| 33 | #ifdef __LP64__ |
| 34 | #define CHECK_MEMBER_AT(type, member, off32, off64) \ |
| 35 | check_member<offsetof(type, member), off64>() |
| 36 | #else |
| 37 | #define CHECK_MEMBER_AT(type, member, off32, off64) \ |
| 38 | check_member<offsetof(type, member), off32>() |
| 39 | #endif |
| 40 | |
| 41 | void CheckOffsets(void) { |
| 42 | //Types defined in hardware.h |
| 43 | CHECK_MEMBER_AT(hw_module_t, tag, 0, 0); |
| 44 | CHECK_MEMBER_AT(hw_module_t, module_api_version, 4, 4); |
| 45 | CHECK_MEMBER_AT(hw_module_t, hal_api_version, 6, 6); |
| 46 | CHECK_MEMBER_AT(hw_module_t, id, 8, 8); |
| 47 | CHECK_MEMBER_AT(hw_module_t, name, 12, 16); |
| 48 | CHECK_MEMBER_AT(hw_module_t, author, 16, 24); |
| 49 | CHECK_MEMBER_AT(hw_module_t, methods, 20, 32); |
| 50 | CHECK_MEMBER_AT(hw_module_t, dso, 24, 40); |
| 51 | CHECK_MEMBER_AT(hw_module_t, reserved, 28, 48); |
| 52 | |
| 53 | CHECK_MEMBER_AT(hw_device_t, tag, 0, 0); |
| 54 | CHECK_MEMBER_AT(hw_device_t, version, 4, 4); |
| 55 | CHECK_MEMBER_AT(hw_device_t, module, 8, 8); |
| 56 | CHECK_MEMBER_AT(hw_device_t, reserved, 12, 16); |
| 57 | CHECK_MEMBER_AT(hw_device_t, close, 60, 112); |
| 58 | |
| 59 | //Types defined in sensors.h |
| 60 | CHECK_MEMBER_AT(sensors_vec_t, v, 0, 0); |
| 61 | CHECK_MEMBER_AT(sensors_vec_t, x, 0, 0); |
| 62 | CHECK_MEMBER_AT(sensors_vec_t, y, 4, 4); |
| 63 | CHECK_MEMBER_AT(sensors_vec_t, z, 8, 8); |
| 64 | CHECK_MEMBER_AT(sensors_vec_t, azimuth, 0, 0); |
| 65 | CHECK_MEMBER_AT(sensors_vec_t, pitch, 4, 4); |
| 66 | CHECK_MEMBER_AT(sensors_vec_t, roll, 8, 8); |
| 67 | CHECK_MEMBER_AT(sensors_vec_t, status, 12, 12); |
| 68 | CHECK_MEMBER_AT(sensors_vec_t, reserved, 13, 13); |
| 69 | |
| 70 | CHECK_MEMBER_AT(sensors_event_t, version, 0, 0); |
| 71 | CHECK_MEMBER_AT(sensors_event_t, sensor, 4, 4); |
| 72 | CHECK_MEMBER_AT(sensors_event_t, type, 8, 8); |
| 73 | CHECK_MEMBER_AT(sensors_event_t, reserved0, 12, 12); |
| 74 | CHECK_MEMBER_AT(sensors_event_t, timestamp, 16, 16); |
| 75 | CHECK_MEMBER_AT(sensors_event_t, data, 24, 24); |
| 76 | CHECK_MEMBER_AT(sensors_event_t, acceleration, 24, 24); |
| 77 | CHECK_MEMBER_AT(sensors_event_t, magnetic, 24, 24); |
| 78 | CHECK_MEMBER_AT(sensors_event_t, orientation, 24, 24); |
| 79 | CHECK_MEMBER_AT(sensors_event_t, gyro, 24, 24); |
| 80 | CHECK_MEMBER_AT(sensors_event_t, temperature, 24, 24); |
| 81 | CHECK_MEMBER_AT(sensors_event_t, distance, 24, 24); |
| 82 | CHECK_MEMBER_AT(sensors_event_t, light, 24, 24); |
| 83 | CHECK_MEMBER_AT(sensors_event_t, pressure, 24, 24); |
| 84 | CHECK_MEMBER_AT(sensors_event_t, relative_humidity, 24, 24); |
| 85 | CHECK_MEMBER_AT(sensors_event_t, uncalibrated_gyro, 24, 24); |
| 86 | CHECK_MEMBER_AT(sensors_event_t, uncalibrated_magnetic, 24, 24); |
| 87 | CHECK_MEMBER_AT(sensors_event_t, meta_data, 24, 24); |
| 88 | CHECK_MEMBER_AT(sensors_event_t, u64, 24, 24); |
| 89 | CHECK_MEMBER_AT(sensors_event_t, u64.data, 24, 24); |
| 90 | CHECK_MEMBER_AT(sensors_event_t, u64.step_counter, 24, 24); |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 91 | CHECK_MEMBER_AT(sensors_event_t, flags, 88, 88); |
| 92 | CHECK_MEMBER_AT(sensors_event_t, reserved1, 92, 92); |
Rom Lemarchand | 1b22d07 | 2013-11-22 14:59:54 -0800 | [diff] [blame] | 93 | |
| 94 | CHECK_MEMBER_AT(struct sensor_t, name, 0, 0); |
| 95 | CHECK_MEMBER_AT(struct sensor_t, vendor, 4, 8); |
| 96 | CHECK_MEMBER_AT(struct sensor_t, version, 8, 16); |
| 97 | CHECK_MEMBER_AT(struct sensor_t, handle, 12, 20); |
| 98 | CHECK_MEMBER_AT(struct sensor_t, type, 16, 24); |
| 99 | CHECK_MEMBER_AT(struct sensor_t, maxRange, 20, 28); |
| 100 | CHECK_MEMBER_AT(struct sensor_t, resolution, 24, 32); |
| 101 | CHECK_MEMBER_AT(struct sensor_t, power, 28, 36); |
| 102 | CHECK_MEMBER_AT(struct sensor_t, minDelay, 32, 40); |
| 103 | CHECK_MEMBER_AT(struct sensor_t, fifoReservedEventCount, 36, 44); |
| 104 | CHECK_MEMBER_AT(struct sensor_t, fifoMaxEventCount, 40, 48); |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 105 | CHECK_MEMBER_AT(struct sensor_t, stringType, 44, 56); |
| 106 | CHECK_MEMBER_AT(struct sensor_t, requiredPermission, 48, 64); |
| 107 | CHECK_MEMBER_AT(struct sensor_t, maxDelay, 52, 72); |
| 108 | CHECK_MEMBER_AT(struct sensor_t, flags, 56, 80); |
| 109 | CHECK_MEMBER_AT(struct sensor_t, reserved, 60, 88); |
Rom Lemarchand | 1b22d07 | 2013-11-22 14:59:54 -0800 | [diff] [blame] | 110 | |
| 111 | CHECK_MEMBER_AT(sensors_poll_device_1_t, v0, 0, 0); |
| 112 | CHECK_MEMBER_AT(sensors_poll_device_1_t, common, 0, 0); |
| 113 | CHECK_MEMBER_AT(sensors_poll_device_1_t, activate, 64, 120); |
| 114 | CHECK_MEMBER_AT(sensors_poll_device_1_t, setDelay, 68, 128); |
| 115 | CHECK_MEMBER_AT(sensors_poll_device_1_t, poll, 72, 136); |
| 116 | CHECK_MEMBER_AT(sensors_poll_device_1_t, batch, 76, 144); |
| 117 | CHECK_MEMBER_AT(sensors_poll_device_1_t, flush, 80, 152); |
| 118 | CHECK_MEMBER_AT(sensors_poll_device_1_t, reserved_procs, 84, 160); |
| 119 | |
| 120 | //Types defined in fb.h |
| 121 | CHECK_MEMBER_AT(framebuffer_device_t, common, 0, 0); |
| 122 | CHECK_MEMBER_AT(framebuffer_device_t, flags, 64, 120); |
| 123 | CHECK_MEMBER_AT(framebuffer_device_t, width, 68, 124); |
| 124 | CHECK_MEMBER_AT(framebuffer_device_t, height, 72, 128); |
| 125 | CHECK_MEMBER_AT(framebuffer_device_t, stride, 76, 132); |
| 126 | CHECK_MEMBER_AT(framebuffer_device_t, format, 80, 136); |
| 127 | CHECK_MEMBER_AT(framebuffer_device_t, xdpi, 84, 140); |
| 128 | CHECK_MEMBER_AT(framebuffer_device_t, ydpi, 88, 144); |
| 129 | CHECK_MEMBER_AT(framebuffer_device_t, fps, 92, 148); |
| 130 | CHECK_MEMBER_AT(framebuffer_device_t, minSwapInterval, 96, 152); |
| 131 | CHECK_MEMBER_AT(framebuffer_device_t, maxSwapInterval, 100, 156); |
| 132 | CHECK_MEMBER_AT(framebuffer_device_t, numFramebuffers, 104, 160); |
| 133 | CHECK_MEMBER_AT(framebuffer_device_t, reserved, 108, 164); |
| 134 | CHECK_MEMBER_AT(framebuffer_device_t, setSwapInterval, 136, 192); |
| 135 | CHECK_MEMBER_AT(framebuffer_device_t, setUpdateRect, 140, 200); |
| 136 | CHECK_MEMBER_AT(framebuffer_device_t, post, 144, 208); |
| 137 | CHECK_MEMBER_AT(framebuffer_device_t, compositionComplete, 148, 216); |
| 138 | CHECK_MEMBER_AT(framebuffer_device_t, dump, 152, 224); |
| 139 | CHECK_MEMBER_AT(framebuffer_device_t, enableScreen, 156, 232); |
| 140 | CHECK_MEMBER_AT(framebuffer_device_t, reserved_proc, 160, 240); |
| 141 | |
| 142 | //Types defined in hwcomposer.h |
| 143 | CHECK_MEMBER_AT(hwc_layer_1_t, compositionType, 0, 0); |
| 144 | CHECK_MEMBER_AT(hwc_layer_1_t, hints, 4, 4); |
| 145 | CHECK_MEMBER_AT(hwc_layer_1_t, flags, 8, 8); |
| 146 | CHECK_MEMBER_AT(hwc_layer_1_t, backgroundColor, 12, 16); |
| 147 | CHECK_MEMBER_AT(hwc_layer_1_t, handle, 12, 16); |
| 148 | CHECK_MEMBER_AT(hwc_layer_1_t, transform, 16, 24); |
| 149 | CHECK_MEMBER_AT(hwc_layer_1_t, blending, 20, 28); |
| 150 | CHECK_MEMBER_AT(hwc_layer_1_t, sourceCropi, 24, 32); |
| 151 | CHECK_MEMBER_AT(hwc_layer_1_t, sourceCrop, 24, 32); |
| 152 | CHECK_MEMBER_AT(hwc_layer_1_t, sourceCropf, 24, 32); |
| 153 | CHECK_MEMBER_AT(hwc_layer_1_t, displayFrame, 40, 48); |
| 154 | CHECK_MEMBER_AT(hwc_layer_1_t, visibleRegionScreen, 56, 64); |
| 155 | CHECK_MEMBER_AT(hwc_layer_1_t, acquireFenceFd, 64, 80); |
| 156 | CHECK_MEMBER_AT(hwc_layer_1_t, releaseFenceFd, 68, 84); |
| 157 | CHECK_MEMBER_AT(hwc_layer_1_t, planeAlpha, 72, 88); |
| 158 | CHECK_MEMBER_AT(hwc_layer_1_t, _pad, 73, 89); |
| 159 | |
| 160 | CHECK_MEMBER_AT(hwc_composer_device_1_t, common, 0, 0); |
| 161 | CHECK_MEMBER_AT(hwc_composer_device_1_t, prepare, 64, 120); |
| 162 | CHECK_MEMBER_AT(hwc_composer_device_1_t, set, 68, 128); |
| 163 | CHECK_MEMBER_AT(hwc_composer_device_1_t, eventControl, 72, 136); |
| 164 | CHECK_MEMBER_AT(hwc_composer_device_1_t, blank, 76, 144); |
| 165 | CHECK_MEMBER_AT(hwc_composer_device_1_t, query, 80, 152); |
| 166 | CHECK_MEMBER_AT(hwc_composer_device_1_t, registerProcs, 84, 160); |
| 167 | CHECK_MEMBER_AT(hwc_composer_device_1_t, dump, 88, 168); |
| 168 | CHECK_MEMBER_AT(hwc_composer_device_1_t, getDisplayConfigs, 92, 176); |
| 169 | CHECK_MEMBER_AT(hwc_composer_device_1_t, getDisplayAttributes, 96, 184); |
| 170 | CHECK_MEMBER_AT(hwc_composer_device_1_t, reserved_proc, 100, 192); |
| 171 | |
| 172 | //Types defined in gralloc.h |
| 173 | CHECK_MEMBER_AT(gralloc_module_t, common, 0, 0); |
| 174 | CHECK_MEMBER_AT(gralloc_module_t, registerBuffer, 128, 248); |
| 175 | CHECK_MEMBER_AT(gralloc_module_t, unregisterBuffer, 132, 256); |
| 176 | CHECK_MEMBER_AT(gralloc_module_t, lock, 136, 264); |
| 177 | CHECK_MEMBER_AT(gralloc_module_t, unlock, 140, 272); |
| 178 | CHECK_MEMBER_AT(gralloc_module_t, perform, 144, 280); |
| 179 | CHECK_MEMBER_AT(gralloc_module_t, lock_ycbcr, 148, 288); |
Greg Hackmann | 1b81911 | 2014-05-12 13:48:30 -0700 | [diff] [blame] | 180 | CHECK_MEMBER_AT(gralloc_module_t, lockAsync, 152, 296); |
| 181 | CHECK_MEMBER_AT(gralloc_module_t, unlockAsync, 156, 304); |
| 182 | CHECK_MEMBER_AT(gralloc_module_t, lockAsync_ycbcr, 160, 312); |
| 183 | CHECK_MEMBER_AT(gralloc_module_t, reserved_proc, 164, 320); |
Rom Lemarchand | 1b22d07 | 2013-11-22 14:59:54 -0800 | [diff] [blame] | 184 | |
| 185 | CHECK_MEMBER_AT(alloc_device_t, common, 0, 0); |
| 186 | CHECK_MEMBER_AT(alloc_device_t, alloc, 64, 120); |
| 187 | CHECK_MEMBER_AT(alloc_device_t, free, 68, 128); |
| 188 | CHECK_MEMBER_AT(alloc_device_t, dump, 72, 136); |
| 189 | CHECK_MEMBER_AT(alloc_device_t, reserved_proc, 76, 144); |
| 190 | |
| 191 | //Types defined in consumerir.h |
| 192 | CHECK_MEMBER_AT(consumerir_device_t, common, 0, 0); |
| 193 | CHECK_MEMBER_AT(consumerir_device_t, transmit, 64, 120); |
| 194 | CHECK_MEMBER_AT(consumerir_device_t, get_num_carrier_freqs, 68, 128); |
| 195 | CHECK_MEMBER_AT(consumerir_device_t, get_carrier_freqs, 72, 136); |
| 196 | CHECK_MEMBER_AT(consumerir_device_t, reserved, 76, 144); |
| 197 | |
| 198 | //Types defined in camera_common.h |
| 199 | CHECK_MEMBER_AT(vendor_tag_ops_t, get_tag_count, 0, 0); |
| 200 | CHECK_MEMBER_AT(vendor_tag_ops_t, get_all_tags, 4, 8); |
| 201 | CHECK_MEMBER_AT(vendor_tag_ops_t, get_section_name, 8, 16); |
| 202 | CHECK_MEMBER_AT(vendor_tag_ops_t, get_tag_name, 12, 24); |
| 203 | CHECK_MEMBER_AT(vendor_tag_ops_t, get_tag_type, 16, 32); |
| 204 | CHECK_MEMBER_AT(vendor_tag_ops_t, reserved, 20, 40); |
| 205 | |
| 206 | CHECK_MEMBER_AT(camera_module_t, common, 0, 0); |
| 207 | CHECK_MEMBER_AT(camera_module_t, get_number_of_cameras, 128, 248); |
| 208 | CHECK_MEMBER_AT(camera_module_t, get_camera_info, 132, 256); |
| 209 | CHECK_MEMBER_AT(camera_module_t, set_callbacks, 136, 264); |
| 210 | CHECK_MEMBER_AT(camera_module_t, get_vendor_tag_ops, 140, 272); |
Greg Hackmann | 16c19a2 | 2014-06-13 13:52:48 -0700 | [diff] [blame] | 211 | CHECK_MEMBER_AT(camera_module_t, open_legacy, 144, 280); |
| 212 | CHECK_MEMBER_AT(camera_module_t, reserved, 148, 288); |
Rom Lemarchand | 1b22d07 | 2013-11-22 14:59:54 -0800 | [diff] [blame] | 213 | |
| 214 | //Types defined in camera3.h |
| 215 | CHECK_MEMBER_AT(camera3_device_ops_t, initialize, 0, 0); |
| 216 | CHECK_MEMBER_AT(camera3_device_ops_t, configure_streams, 4, 8); |
| 217 | CHECK_MEMBER_AT(camera3_device_ops_t, register_stream_buffers, 8, 16); |
| 218 | CHECK_MEMBER_AT(camera3_device_ops_t, construct_default_request_settings, 12, 24); |
| 219 | CHECK_MEMBER_AT(camera3_device_ops_t, process_capture_request, 16, 32); |
| 220 | CHECK_MEMBER_AT(camera3_device_ops_t, get_metadata_vendor_tag_ops, 20, 40); |
| 221 | CHECK_MEMBER_AT(camera3_device_ops_t, dump, 24, 48); |
| 222 | CHECK_MEMBER_AT(camera3_device_ops_t, flush, 28, 56); |
| 223 | CHECK_MEMBER_AT(camera3_device_ops_t, reserved, 32, 64); |
| 224 | } |
| 225 | |