blob: 97bc99544a458db8a079eb6cf3e18b2fdd748f1c [file] [log] [blame]
Amy Zhangbb94eeb2020-07-09 22:48:04 -07001/*
2 * Copyright 2020 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
17#ifndef ANDROID_HARDWARE_TV_TUNER_V1_1_TUNER_H_
18#define ANDROID_HARDWARE_TV_TUNER_V1_1_TUNER_H_
19
20#include <android/hardware/tv/tuner/1.1/ITuner.h>
21#include <map>
22#include "Demux.h"
23#include "Frontend.h"
24#include "Lnb.h"
25
26using namespace std;
27
28namespace android {
29namespace hardware {
30namespace tv {
31namespace tuner {
32namespace V1_0 {
33namespace implementation {
34
35using ::android::hardware::tv::tuner::V1_1::ITuner;
36
37class Frontend;
38class Demux;
39class Lnb;
40
41class Tuner : public ITuner {
42 public:
43 Tuner();
44
45 virtual Return<void> getFrontendIds(getFrontendIds_cb _hidl_cb) override;
46
47 virtual Return<void> openFrontendById(uint32_t frontendId,
48 openFrontendById_cb _hidl_cb) override;
49
50 virtual Return<void> openDemux(openDemux_cb _hidl_cb) override;
51
52 virtual Return<void> getDemuxCaps(getDemuxCaps_cb _hidl_cb) override;
53
54 virtual Return<void> openDescrambler(openDescrambler_cb _hidl_cb) override;
55
56 virtual Return<void> getFrontendInfo(uint32_t frontendId, getFrontendInfo_cb _hidl_cb) override;
57
58 virtual Return<void> getLnbIds(getLnbIds_cb _hidl_cb) override;
59
60 virtual Return<void> openLnbById(uint32_t lnbId, openLnbById_cb _hidl_cb) override;
61
62 virtual Return<void> openLnbByName(const hidl_string& lnbName,
63 openLnbByName_cb _hidl_cb) override;
64
Amy Zhang4c49c152020-08-25 21:08:19 -070065 virtual Return<void> getFrontendDtmbCapabilities(
66 uint32_t frontendId, getFrontendDtmbCapabilities_cb _hidl_cb) override;
67
Amy Zhangbb94eeb2020-07-09 22:48:04 -070068 sp<Frontend> getFrontendById(uint32_t frontendId);
69
70 void setFrontendAsDemuxSource(uint32_t frontendId, uint32_t demuxId);
71
72 void frontendStartTune(uint32_t frontendId);
73 void frontendStopTune(uint32_t frontendId);
Amy Zhang80cb9602020-07-15 13:06:39 -070074 void removeDemux(uint32_t demuxId);
75 void removeFrontend(uint32_t frontendId);
Amy Zhangbb94eeb2020-07-09 22:48:04 -070076
77 private:
78 virtual ~Tuner();
79 // Static mFrontends array to maintain local frontends information
Amy Zhang80cb9602020-07-15 13:06:39 -070080 map<uint32_t, sp<Frontend>> mFrontends;
81 map<uint32_t, FrontendInfo::FrontendCapabilities> mFrontendCaps;
Amy Zhang7394e622021-02-23 22:29:48 -080082 map<uint32_t, vector<FrontendStatusType>> mFrontendStatusCaps;
Amy Zhang4c49c152020-08-25 21:08:19 -070083 V1_1::FrontendDtmbCapabilities mDtmbCaps;
Amy Zhang80cb9602020-07-15 13:06:39 -070084 map<uint32_t, uint32_t> mFrontendToDemux;
85 map<uint32_t, sp<Demux>> mDemuxes;
Amy Zhangbb94eeb2020-07-09 22:48:04 -070086 // To maintain how many Frontends we have
87 int mFrontendSize;
88 // The last used demux id. Initial value is -1.
89 // First used id will be 0.
90 uint32_t mLastUsedId = -1;
91 vector<sp<Lnb>> mLnbs;
92};
93
94} // namespace implementation
95} // namespace V1_0
96} // namespace tuner
97} // namespace tv
98} // namespace hardware
99} // namespace android
100
101#endif // ANDROID_HARDWARE_TV_TUNER_V1_1_TUNER_H_