blob: 17ee99f0d1edf61261f020a8503358128340fea1 [file] [log] [blame]
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -08001/*
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
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070019#include "VirtualRadio.h"
20
21#include <WorkerThread.h>
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080022#include <android/hardware/broadcastradio/1.1/ITuner.h>
23#include <android/hardware/broadcastradio/1.1/ITunerCallback.h>
24
25namespace android {
26namespace hardware {
27namespace broadcastradio {
28namespace V1_1 {
29namespace implementation {
30
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080031struct Tuner : public ITuner {
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070032 Tuner(const sp<V1_0::ITunerCallback>& callback);
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080033
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070034 void forceClose();
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080035
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070036 // V1_1::ITuner methods
37 Return<Result> setConfiguration(const V1_0::BandConfig& config) override;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080038 Return<void> getConfiguration(getConfiguration_cb _hidl_cb) override;
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070039 Return<Result> scan(V1_0::Direction direction, bool skipSubChannel) override;
40 Return<Result> step(V1_0::Direction direction, bool skipSubChannel) override;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080041 Return<Result> tune(uint32_t channel, uint32_t subChannel) override;
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -070042 Return<Result> tune_1_1(const ProgramSelector& program) override;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080043 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;
Tomasz Wasilczyk803301a2017-03-13 14:30:15 -070046 Return<ProgramListResult> startBackgroundScan() override;
Tomasz Wasilczyk2dd1d8d2017-03-01 14:21:07 -080047 Return<void> getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override;
Tomasz Wasilczykc7002822017-03-27 14:29:16 -070048 Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
49 Return<Result> setAnalogForced(bool isForced) override;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080050
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070051 private:
52 std::mutex mMut;
53 WorkerThread mThread;
54 bool mIsClosed = false; // TODO(b/36864090): use it
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080055
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080056 const sp<V1_0::ITunerCallback> mCallback;
57 const sp<V1_1::ITunerCallback> mCallback1_1;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080058
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070059 VirtualRadio mVirtualFm;
60
61 bool mIsAmfmConfigSet = false;
62 V1_0::BandConfig mAmfmConfig;
63 bool mIsTuneCompleted = false;
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -070064 ProgramSelector mCurrentProgram = {};
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070065 ProgramInfo mCurrentProgramInfo = {};
66
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -070067 void tuneInternalLocked(const ProgramSelector& sel);
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070068};
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080069
70} // namespace implementation
71} // namespace V1_1
72} // namespace broadcastradio
73} // namespace hardware
74} // namespace android
75
76#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H