blob: 7719d4d581401151f3bfb79f3000b325f127b4b8 [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;
42 Return<Result> cancel() override;
43 Return<void> getProgramInformation(getProgramInformation_cb _hidl_cb) override;
44 Return<void> getProgramInformation_1_1(getProgramInformation_1_1_cb _hidl_cb) override;
Tomasz Wasilczyk803301a2017-03-13 14:30:15 -070045 Return<ProgramListResult> startBackgroundScan() override;
Tomasz Wasilczyk2dd1d8d2017-03-01 14:21:07 -080046 Return<void> getProgramList(const hidl_string& filter, getProgramList_cb _hidl_cb) override;
Tomasz Wasilczykc7002822017-03-27 14:29:16 -070047 Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
48 Return<Result> setAnalogForced(bool isForced) override;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080049
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070050 private:
51 std::mutex mMut;
52 WorkerThread mThread;
53 bool mIsClosed = false; // TODO(b/36864090): use it
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080054
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080055 const sp<V1_0::ITunerCallback> mCallback;
56 const sp<V1_1::ITunerCallback> mCallback1_1;
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080057
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070058 VirtualRadio mVirtualFm;
59
60 bool mIsAmfmConfigSet = false;
61 V1_0::BandConfig mAmfmConfig;
62 bool mIsTuneCompleted = false;
63 uint32_t mCurrentProgram; // TODO(b/32621193): Station Selector
64 ProgramInfo mCurrentProgramInfo = {};
65
66 void tuneInternalLocked();
67};
Tomasz Wasilczyk213170b2017-02-07 17:38:21 -080068
69} // namespace implementation
70} // namespace V1_1
71} // namespace broadcastradio
72} // namespace hardware
73} // namespace android
74
75#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_TUNER_H