2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef ANDROID_LOCAL_TIME_HAL_INTERFACE_H
19 #define ANDROID_LOCAL_TIME_HAL_INTERFACE_H
23 #include <hardware/hardware.h>
28 * The id of this module
30 #define LOCAL_TIME_HARDWARE_MODULE_ID "local_time"
33 * Name of the local time devices to open
35 #define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if"
37 /**********************************************************************/
40 * A structure used to collect low level sync data in a lab environment. Most
41 * HAL implementations will never need this structure.
43 struct local_time_debug_event
{
44 int64_t local_timesync_event_id
;
49 * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
50 * and the fields of this data structure must begin with hw_module_t
51 * followed by module specific information.
53 struct local_time_module
{
54 struct hw_module_t common
;
57 struct local_time_hw_device
{
58 struct hw_device_t common
;
62 * Returns the current value of the system wide local time counter
64 int64_t (*get_local_time
)(struct local_time_hw_device
* dev
);
68 * Returns the nominal frequency (in hertz) of the system wide local time
71 uint64_t (*get_local_freq
)(struct local_time_hw_device
* dev
);
75 * Sets the HW slew rate of oscillator which drives the system wide local
76 * time counter. On success, platforms should return 0. Platforms which
77 * do not support HW slew should leave this method set to NULL.
79 * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform
80 * implementations should attempt map this range linearly to the min/max
81 * slew rate of their hardware.
83 int (*set_local_slew
)(struct local_time_hw_device
* dev
, int16_t rate
);
87 * A method used to collect low level sync data in a lab environments.
88 * Most HAL implementations will simply set this member to NULL, or return
89 * -EINVAL to indicate that this functionality is not supported.
90 * Production HALs should never support this method.
92 int (*get_debug_log
)(struct local_time_hw_device
* dev
,
93 struct local_time_debug_event
* records
,
97 typedef struct local_time_hw_device local_time_hw_device_t
;
99 /** convenience API for opening and closing a supported device */
101 static inline int local_time_hw_device_open(
102 const struct hw_module_t
* module
,
103 struct local_time_hw_device
** device
)
105 return module
->methods
->open(module
, LOCAL_TIME_HARDWARE_INTERFACE
,
106 (struct hw_device_t
**)device
);
109 static inline int local_time_hw_device_close(struct local_time_hw_device
* device
)
111 return device
->common
.close(&device
->common
);
117 #endif // ANDROID_LOCAL_TIME_INTERFACE_H