local_clock.h revision ea7939a079b3600cab955760839b021326f8cfc3
1951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen/*
2951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Copyright (C) 2011 The Android Open Source Project
3951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *
4951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Licensed under the Apache License, Version 2.0 (the "License");
5951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * you may not use this file except in compliance with the License.
6951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * You may obtain a copy of the License at
7951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *
8951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *      http://www.apache.org/licenses/LICENSE-2.0
9951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen *
10951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * Unless required by applicable law or agreed to in writing, software
11951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * distributed under the License is distributed on an "AS IS" BASIS,
12951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * See the License for the specific language governing permissions and
14951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen * limitations under the License.
15951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen */
16951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
17951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
18951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#ifndef __LOCAL_CLOCK_H__
19951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#define __LOCAL_CLOCK_H__
20951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
21951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <stdint.h>
22951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
23951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <hardware/local_time_hal.h>
24951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <utils/Errors.h>
25951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#include <utils/threads.h>
26951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
27951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chennamespace android {
28951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
29951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chenclass LocalClock {
30951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen  public:
31ea7939a079b3600cab955760839b021326f8cfc3Glenn Kasten    LocalClock();
32951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
33951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    bool initCheck();
34951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
35951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    int64_t  getLocalTime();
36951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    uint64_t getLocalFreq();
37951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    status_t setLocalSlew(int16_t rate);
38951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    int32_t  getDebugLog(struct local_time_debug_event* records,
39951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen                         int max_records);
40951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
41951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen  private:
42951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    static Mutex dev_lock_;
43951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen    static local_time_hw_device_t* dev_;
44951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen};
45951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen
46951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen}  // namespace android
47951bd8d1ad9581a414e171ad8605a9515d0ad667Mike J. Chen#endif  // __LOCAL_CLOCK_H__
48