1 /* 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_FRONTEND_H_ 18 #define ANDROID_HARDWARE_TV_TUNER_V1_1_FRONTEND_H_ 19 20 #include <android/hardware/tv/tuner/1.1/IFrontend.h> 21 #include <fstream> 22 #include <iostream> 23 #include <thread> 24 #include "Tuner.h" 25 26 using namespace std; 27 28 namespace android { 29 namespace hardware { 30 namespace tv { 31 namespace tuner { 32 namespace V1_0 { 33 namespace implementation { 34 35 class Tuner; 36 37 class Frontend : public V1_1::IFrontend { 38 public: 39 Frontend(FrontendType type, FrontendId id, sp<Tuner> tuner); 40 41 virtual Return<Result> close() override; 42 43 virtual Return<Result> setCallback(const sp<IFrontendCallback>& callback) override; 44 45 virtual Return<Result> tune(const FrontendSettings& settings) override; 46 47 virtual Return<Result> tune_1_1(const FrontendSettings& settings, 48 const V1_1::FrontendSettingsExt1_1& settingsExt1_1) override; 49 50 virtual Return<Result> stopTune() override; 51 52 virtual Return<Result> scan(const FrontendSettings& settings, FrontendScanType type) override; 53 54 virtual Return<Result> scan_1_1(const FrontendSettings& settings, FrontendScanType type, 55 const V1_1::FrontendSettingsExt1_1& settingsExt1_1) override; 56 57 virtual Return<Result> stopScan() override; 58 59 virtual Return<void> getStatus(const hidl_vec<FrontendStatusType>& statusTypes, 60 getStatus_cb _hidl_cb) override; 61 62 virtual Return<void> getStatusExt1_1( 63 const hidl_vec<V1_1::FrontendStatusTypeExt1_1>& statusTypes, 64 V1_1::IFrontend::getStatusExt1_1_cb _hidl_cb) override; 65 66 virtual Return<Result> setLna(bool bEnable) override; 67 68 virtual Return<Result> setLnb(uint32_t lnb) override; 69 70 virtual Return<void> linkCiCam(uint32_t ciCamId, linkCiCam_cb _hidl_cb) override; 71 72 virtual Return<Result> unlinkCiCam(uint32_t ciCamId) override; 73 74 FrontendType getFrontendType(); 75 76 FrontendId getFrontendId(); 77 78 string getSourceFile(); 79 80 bool isLocked(); 81 82 private: 83 virtual ~Frontend(); 84 bool supportsSatellite(); 85 void scanThreadLoop(); 86 87 sp<IFrontendCallback> mCallback; 88 sp<Tuner> mTunerService; 89 FrontendType mType = FrontendType::UNDEFINED; 90 FrontendId mId = 0; 91 bool mIsLocked = false; 92 uint32_t mCiCamId; 93 std::thread mScanThread; 94 FrontendSettings mFrontendSettings; 95 FrontendScanType mFrontendScanType; 96 std::ifstream mFrontendData; 97 }; 98 99 } // namespace implementation 100 } // namespace V1_0 101 } // namespace tuner 102 } // namespace tv 103 } // namespace hardware 104 } // namespace android 105 106 #endif // ANDROID_HARDWARE_TV_TUNER_V1_1_FRONTEND_H_ 107