OSDN Git Service

release-request-e04bb055-13fc-41a1-8a9f-7fb10894ec3d-for-git_oc-mr1-release-4189380...
[android-x86/hardware-interfaces.git] / broadcastradio / 1.1 / default / Tuner.h
1 /*
2  * Copyright (C) 2017 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 #ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
17 #define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H
18
19 #include "VirtualRadio.h"
20
21 #include <WorkerThread.h>
22 #include <android/hardware/broadcastradio/1.1/ITuner.h>
23 #include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
24
25 namespace android {
26 namespace hardware {
27 namespace broadcastradio {
28 namespace V1_1 {
29 namespace implementation {
30
31 struct Tuner : public ITuner {
32     Tuner(const sp<V1_0::ITunerCallback>& callback);
33
34     void forceClose();
35
36     // V1_1::ITuner methods
37     Return<Result> setConfiguration(const V1_0::BandConfig& config) override;
38     Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
39     Return<Result> scan(V1_0::Direction direction, bool skipSubChannel) override;
40     Return<Result> step(V1_0::Direction direction, bool skipSubChannel) override;
41     Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
42     Return<Result> tune_1_1(const ProgramSelector& program) override;
43     Return<Result> cancel() override;
44     Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
45     Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
46     Return<ProgramListResult> startBackgroundScan() override;
47     Return<void> getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override;
48     Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
49     Return<Result> setAnalogForced(bool isForced) override;
50
51    private:
52     std::mutex mMut;
53     WorkerThread mThread;
54     bool mIsClosed = false;  // TODO(b/36864090): use it
55
56     const sp<V1_0::ITunerCallback> mCallback;
57     const sp<V1_1::ITunerCallback> mCallback1_1;
58
59     VirtualRadio mVirtualFm;
60
61     bool mIsAmfmConfigSet = false;
62     V1_0::BandConfig mAmfmConfig;
63     bool mIsTuneCompleted = false;
64     ProgramSelector mCurrentProgram = {};
65     ProgramInfo mCurrentProgramInfo = {};
66
67     void tuneInternalLocked(const ProgramSelector& sel);
68     bool isFmLocked();  // TODO(b/36864090): make it generic, not FM only
69 };
70
71 }  // namespace implementation
72 }  // namespace V1_1
73 }  // namespace broadcastradio
74 }  // namespace hardware
75 }  // namespace android
76
77 #endif  // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H