2 * Copyright (C) 2012 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.
17 #ifndef __COMMON_CLOCK_H__
18 #define __COMMON_CLOCK_H__
22 #include <utils/Errors.h>
23 #include <utils/LinearTransform.h>
24 #include <utils/threads.h>
32 bool init(uint64_t local_freq);
34 status_t localToCommon(int64_t local, int64_t *common_out) const;
35 status_t commonToLocal(int64_t common, int64_t *local_out) const;
36 int64_t localDurationToCommonDuration(int64_t localDur) const;
37 uint64_t getCommonFreq() const { return kCommonFreq; }
38 bool isValid() const { return cur_trans_valid_; }
39 status_t setSlew(int64_t change_time, int32_t ppm);
40 void setBasis(int64_t local, int64_t common);
46 uint32_t local_to_common_freq_numer_;
47 uint32_t local_to_common_freq_denom_;
49 LinearTransform duration_trans_;
50 LinearTransform cur_trans_;
51 bool cur_trans_valid_;
53 static const uint64_t kCommonFreq = 1000000ull;
56 } // namespace android
57 #endif // __COMMON_CLOCK_H__