Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 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 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "android.hardware.tv.tuner-service.example-Tuner" |
| 19 | |
Hongguang | e423acd | 2021-07-27 16:56:47 -0700 | [diff] [blame] | 20 | #include <aidl/android/hardware/tv/tuner/Result.h> |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 21 | #include <utils/Log.h> |
Hongguang | e423acd | 2021-07-27 16:56:47 -0700 | [diff] [blame] | 22 | |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 23 | #include "Demux.h" |
| 24 | #include "Descrambler.h" |
| 25 | #include "Frontend.h" |
| 26 | #include "Lnb.h" |
Hongguang | e423acd | 2021-07-27 16:56:47 -0700 | [diff] [blame] | 27 | #include "Tuner.h" |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 28 | |
| 29 | namespace aidl { |
| 30 | namespace android { |
| 31 | namespace hardware { |
| 32 | namespace tv { |
| 33 | namespace tuner { |
| 34 | |
Hongguang Chen | ff2c6b0 | 2021-08-07 00:12:26 +0000 | [diff] [blame] | 35 | Tuner::Tuner() {} |
| 36 | |
| 37 | void Tuner::init() { |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 38 | // Static Frontends array to maintain local frontends information |
| 39 | // Array index matches their FrontendId in the default impl |
| 40 | mFrontendSize = 10; |
Hongguang Chen | ff2c6b0 | 2021-08-07 00:12:26 +0000 | [diff] [blame] | 41 | mFrontends[0] = ndk::SharedRefBase::make<Frontend>(FrontendType::ISDBS, 0, this->ref<Tuner>()); |
| 42 | mFrontends[1] = ndk::SharedRefBase::make<Frontend>(FrontendType::ATSC3, 1, this->ref<Tuner>()); |
| 43 | mFrontends[2] = ndk::SharedRefBase::make<Frontend>(FrontendType::DVBC, 2, this->ref<Tuner>()); |
| 44 | mFrontends[3] = ndk::SharedRefBase::make<Frontend>(FrontendType::DVBS, 3, this->ref<Tuner>()); |
| 45 | mFrontends[4] = ndk::SharedRefBase::make<Frontend>(FrontendType::DVBT, 4, this->ref<Tuner>()); |
| 46 | mFrontends[5] = ndk::SharedRefBase::make<Frontend>(FrontendType::ISDBT, 5, this->ref<Tuner>()); |
| 47 | mFrontends[6] = ndk::SharedRefBase::make<Frontend>(FrontendType::ANALOG, 6, this->ref<Tuner>()); |
| 48 | mFrontends[7] = ndk::SharedRefBase::make<Frontend>(FrontendType::ATSC, 7, this->ref<Tuner>()); |
| 49 | mFrontends[8] = ndk::SharedRefBase::make<Frontend>(FrontendType::ISDBS3, 8, this->ref<Tuner>()); |
| 50 | mFrontends[9] = ndk::SharedRefBase::make<Frontend>(FrontendType::DTMB, 9, this->ref<Tuner>()); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 51 | |
| 52 | vector<FrontendStatusType> statusCaps; |
| 53 | |
| 54 | FrontendCapabilities capsIsdbs; |
| 55 | capsIsdbs.set<FrontendCapabilities::Tag::isdbsCaps>(FrontendIsdbsCapabilities()); |
| 56 | mFrontendCaps[0] = capsIsdbs; |
| 57 | statusCaps = { |
Hongguang | 2ecfc39 | 2021-11-23 10:29:15 -0800 | [diff] [blame] | 58 | FrontendStatusType::DEMOD_LOCK, |
| 59 | FrontendStatusType::SNR, |
| 60 | FrontendStatusType::FEC, |
| 61 | FrontendStatusType::MODULATION, |
| 62 | FrontendStatusType::MODULATIONS, |
| 63 | FrontendStatusType::ROLL_OFF, |
| 64 | FrontendStatusType::STREAM_ID_LIST, |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 65 | }; |
| 66 | mFrontendStatusCaps[0] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 67 | mMaxUsableFrontends[FrontendType::ISDBS] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 68 | |
| 69 | FrontendCapabilities capsAtsc3; |
| 70 | capsAtsc3.set<FrontendCapabilities::Tag::atsc3Caps>(FrontendAtsc3Capabilities()); |
| 71 | mFrontendCaps[1] = capsAtsc3; |
| 72 | statusCaps = { |
| 73 | FrontendStatusType::BER, |
| 74 | FrontendStatusType::PER, |
| 75 | FrontendStatusType::ATSC3_PLP_INFO, |
| 76 | FrontendStatusType::MODULATIONS, |
| 77 | FrontendStatusType::BERS, |
| 78 | FrontendStatusType::INTERLEAVINGS, |
| 79 | FrontendStatusType::BANDWIDTH, |
| 80 | }; |
| 81 | mFrontendStatusCaps[1] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 82 | mMaxUsableFrontends[FrontendType::ATSC3] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 83 | |
| 84 | FrontendCapabilities capsDvbc; |
| 85 | capsDvbc.set<FrontendCapabilities::Tag::dvbcCaps>(FrontendDvbcCapabilities()); |
| 86 | mFrontendCaps[2] = capsDvbc; |
| 87 | statusCaps = { |
| 88 | FrontendStatusType::PRE_BER, FrontendStatusType::SIGNAL_QUALITY, |
| 89 | FrontendStatusType::MODULATION, FrontendStatusType::SPECTRAL, |
| 90 | FrontendStatusType::MODULATIONS, FrontendStatusType::CODERATES, |
| 91 | FrontendStatusType::INTERLEAVINGS, FrontendStatusType::BANDWIDTH, |
| 92 | }; |
| 93 | mFrontendStatusCaps[2] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 94 | mMaxUsableFrontends[FrontendType::DVBC] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 95 | |
| 96 | FrontendCapabilities capsDvbs; |
| 97 | capsDvbs.set<FrontendCapabilities::Tag::dvbsCaps>(FrontendDvbsCapabilities()); |
| 98 | mFrontendCaps[3] = capsDvbs; |
| 99 | statusCaps = { |
| 100 | FrontendStatusType::SIGNAL_STRENGTH, FrontendStatusType::SYMBOL_RATE, |
| 101 | FrontendStatusType::MODULATION, FrontendStatusType::MODULATIONS, |
| 102 | FrontendStatusType::ROLL_OFF, FrontendStatusType::IS_MISO, |
| 103 | }; |
| 104 | mFrontendStatusCaps[3] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 105 | mMaxUsableFrontends[FrontendType::DVBS] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 106 | |
| 107 | FrontendCapabilities capsDvbt; |
| 108 | capsDvbt.set<FrontendCapabilities::Tag::dvbtCaps>(FrontendDvbtCapabilities()); |
| 109 | mFrontendCaps[4] = capsDvbt; |
| 110 | statusCaps = { |
| 111 | FrontendStatusType::EWBS, |
| 112 | FrontendStatusType::PLP_ID, |
| 113 | FrontendStatusType::HIERARCHY, |
| 114 | FrontendStatusType::MODULATIONS, |
| 115 | FrontendStatusType::BANDWIDTH, |
| 116 | FrontendStatusType::GUARD_INTERVAL, |
| 117 | FrontendStatusType::TRANSMISSION_MODE, |
| 118 | FrontendStatusType::T2_SYSTEM_ID, |
Hongguang | 7eda782 | 2021-12-20 14:48:14 -0800 | [diff] [blame] | 119 | FrontendStatusType::DVBT_CELL_IDS, |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 120 | }; |
| 121 | mFrontendStatusCaps[4] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 122 | mMaxUsableFrontends[FrontendType::DVBT] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 123 | |
| 124 | FrontendCapabilities capsIsdbt; |
| 125 | FrontendIsdbtCapabilities isdbtCaps{ |
| 126 | .modeCap = (int)FrontendIsdbtMode::MODE_1 | (int)FrontendIsdbtMode::MODE_2, |
| 127 | .bandwidthCap = (int)FrontendIsdbtBandwidth::BANDWIDTH_6MHZ, |
| 128 | .modulationCap = (int)FrontendIsdbtModulation::MOD_16QAM, |
Hongguang | e69a3b2 | 2021-08-03 14:23:42 -0700 | [diff] [blame] | 129 | .coderateCap = (int)FrontendIsdbtCoderate::CODERATE_4_5 | |
| 130 | (int)FrontendIsdbtCoderate::CODERATE_6_7, |
| 131 | .guardIntervalCap = (int)FrontendIsdbtGuardInterval::INTERVAL_1_128, |
Hongguang | 788284f | 2021-10-28 15:03:29 -0700 | [diff] [blame] | 132 | .timeInterleaveCap = (int)FrontendIsdbtTimeInterleaveMode::AUTO | |
| 133 | (int)FrontendIsdbtTimeInterleaveMode::INTERLEAVE_1_0, |
| 134 | .isSegmentAuto = true, |
| 135 | .isFullSegment = true, |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 136 | }; |
| 137 | capsIsdbt.set<FrontendCapabilities::Tag::isdbtCaps>(isdbtCaps); |
| 138 | mFrontendCaps[5] = capsIsdbt; |
| 139 | statusCaps = { |
| 140 | FrontendStatusType::AGC, |
| 141 | FrontendStatusType::LNA, |
| 142 | FrontendStatusType::MODULATION, |
| 143 | FrontendStatusType::MODULATIONS, |
| 144 | FrontendStatusType::BANDWIDTH, |
| 145 | FrontendStatusType::GUARD_INTERVAL, |
| 146 | FrontendStatusType::TRANSMISSION_MODE, |
| 147 | FrontendStatusType::ISDBT_SEGMENTS, |
Hongguang | 788284f | 2021-10-28 15:03:29 -0700 | [diff] [blame] | 148 | FrontendStatusType::ISDBT_MODE, |
| 149 | FrontendStatusType::ISDBT_PARTIAL_RECEPTION_FLAG, |
| 150 | FrontendStatusType::INTERLEAVINGS, |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 151 | }; |
| 152 | mFrontendStatusCaps[5] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 153 | mMaxUsableFrontends[FrontendType::ISDBT] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 154 | |
| 155 | FrontendCapabilities capsAnalog; |
| 156 | capsAnalog.set<FrontendCapabilities::Tag::analogCaps>(FrontendAnalogCapabilities()); |
| 157 | mFrontendCaps[6] = capsAnalog; |
| 158 | statusCaps = { |
| 159 | FrontendStatusType::LAYER_ERROR, |
| 160 | FrontendStatusType::MER, |
| 161 | FrontendStatusType::UEC, |
| 162 | FrontendStatusType::TS_DATA_RATES, |
| 163 | }; |
| 164 | mFrontendStatusCaps[6] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 165 | mMaxUsableFrontends[FrontendType::ANALOG] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 166 | |
| 167 | FrontendCapabilities capsAtsc; |
| 168 | capsAtsc.set<FrontendCapabilities::Tag::atscCaps>(FrontendAtscCapabilities()); |
| 169 | mFrontendCaps[7] = capsAtsc; |
| 170 | statusCaps = { |
| 171 | FrontendStatusType::FREQ_OFFSET, |
| 172 | FrontendStatusType::RF_LOCK, |
| 173 | FrontendStatusType::MODULATIONS, |
| 174 | FrontendStatusType::IS_LINEAR, |
| 175 | }; |
| 176 | mFrontendStatusCaps[7] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 177 | mMaxUsableFrontends[FrontendType::ATSC] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 178 | |
| 179 | FrontendCapabilities capsIsdbs3; |
| 180 | capsIsdbs3.set<FrontendCapabilities::Tag::isdbs3Caps>(FrontendIsdbs3Capabilities()); |
| 181 | mFrontendCaps[8] = capsIsdbs3; |
| 182 | statusCaps = { |
| 183 | FrontendStatusType::DEMOD_LOCK, FrontendStatusType::MODULATION, |
| 184 | FrontendStatusType::MODULATIONS, FrontendStatusType::ROLL_OFF, |
Hongguang | 2ecfc39 | 2021-11-23 10:29:15 -0800 | [diff] [blame] | 185 | FrontendStatusType::IS_SHORT_FRAMES, FrontendStatusType::STREAM_ID_LIST, |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 186 | }; |
| 187 | mFrontendStatusCaps[8] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 188 | mMaxUsableFrontends[FrontendType::ISDBS3] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 189 | |
| 190 | FrontendCapabilities capsDtmb; |
| 191 | capsDtmb.set<FrontendCapabilities::Tag::dtmbCaps>(FrontendDtmbCapabilities()); |
| 192 | mFrontendCaps[9] = capsDtmb; |
| 193 | statusCaps = { |
| 194 | FrontendStatusType::MODULATIONS, FrontendStatusType::INTERLEAVINGS, |
| 195 | FrontendStatusType::BANDWIDTH, FrontendStatusType::GUARD_INTERVAL, |
| 196 | FrontendStatusType::TRANSMISSION_MODE, |
| 197 | }; |
| 198 | mFrontendStatusCaps[9] = statusCaps; |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 199 | mMaxUsableFrontends[FrontendType::DTMB] = 1; |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 200 | |
| 201 | mLnbs.resize(2); |
| 202 | mLnbs[0] = ndk::SharedRefBase::make<Lnb>(0); |
| 203 | mLnbs[1] = ndk::SharedRefBase::make<Lnb>(1); |
| 204 | } |
| 205 | |
| 206 | Tuner::~Tuner() {} |
| 207 | |
| 208 | ::ndk::ScopedAStatus Tuner::getFrontendIds(std::vector<int32_t>* _aidl_return) { |
| 209 | ALOGV("%s", __FUNCTION__); |
| 210 | |
| 211 | _aidl_return->resize(mFrontendSize); |
| 212 | for (int i = 0; i < mFrontendSize; i++) { |
| 213 | (*_aidl_return)[i] = mFrontends[i]->getFrontendId(); |
| 214 | } |
| 215 | |
| 216 | return ::ndk::ScopedAStatus::ok(); |
| 217 | } |
| 218 | |
| 219 | ::ndk::ScopedAStatus Tuner::openFrontendById(int32_t in_frontendId, |
| 220 | std::shared_ptr<IFrontend>* _aidl_return) { |
| 221 | ALOGV("%s", __FUNCTION__); |
| 222 | |
| 223 | if (in_frontendId >= mFrontendSize || in_frontendId < 0) { |
| 224 | ALOGW("[ WARN ] Frontend with id %d isn't available", in_frontendId); |
| 225 | *_aidl_return = nullptr; |
Hongguang | e423acd | 2021-07-27 16:56:47 -0700 | [diff] [blame] | 226 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 227 | static_cast<int32_t>(Result::INVALID_ARGUMENT)); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | *_aidl_return = mFrontends[in_frontendId]; |
| 231 | return ::ndk::ScopedAStatus::ok(); |
| 232 | } |
| 233 | |
| 234 | ::ndk::ScopedAStatus Tuner::openDemux(std::vector<int32_t>* out_demuxId, |
| 235 | std::shared_ptr<IDemux>* _aidl_return) { |
| 236 | ALOGV("%s", __FUNCTION__); |
| 237 | |
| 238 | mLastUsedId += 1; |
Hongguang Chen | ff2c6b0 | 2021-08-07 00:12:26 +0000 | [diff] [blame] | 239 | mDemuxes[mLastUsedId] = ndk::SharedRefBase::make<Demux>(mLastUsedId, this->ref<Tuner>()); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 240 | |
| 241 | out_demuxId->push_back(mLastUsedId); |
| 242 | *_aidl_return = mDemuxes[mLastUsedId]; |
| 243 | |
| 244 | return ::ndk::ScopedAStatus::ok(); |
| 245 | } |
| 246 | |
| 247 | ::ndk::ScopedAStatus Tuner::getDemuxCaps(DemuxCapabilities* _aidl_return) { |
| 248 | ALOGV("%s", __FUNCTION__); |
| 249 | |
| 250 | // IP filter can be an MMTP filter's data source. |
| 251 | _aidl_return->linkCaps = {0x00, 0x00, 0x02, 0x00, 0x00}; |
| 252 | // Support time filter testing |
| 253 | _aidl_return->bTimeFilter = true; |
| 254 | |
| 255 | return ::ndk::ScopedAStatus::ok(); |
| 256 | } |
| 257 | |
| 258 | ::ndk::ScopedAStatus Tuner::openDescrambler(std::shared_ptr<IDescrambler>* _aidl_return) { |
| 259 | ALOGV("%s", __FUNCTION__); |
| 260 | |
| 261 | *_aidl_return = ndk::SharedRefBase::make<Descrambler>(); |
| 262 | |
| 263 | return ndk::ScopedAStatus::ok(); |
| 264 | } |
| 265 | |
| 266 | ::ndk::ScopedAStatus Tuner::getFrontendInfo(int32_t in_frontendId, FrontendInfo* _aidl_return) { |
| 267 | ALOGV("%s", __FUNCTION__); |
| 268 | |
| 269 | if (in_frontendId >= mFrontendSize) { |
Hongguang | e423acd | 2021-07-27 16:56:47 -0700 | [diff] [blame] | 270 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 271 | static_cast<int32_t>(Result::INVALID_ARGUMENT)); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | // assign randomly selected values for testing. |
| 275 | *_aidl_return = { |
| 276 | .type = mFrontends[in_frontendId]->getFrontendType(), |
Gareth Fenn | 282fb37 | 2021-09-27 15:14:11 +0100 | [diff] [blame] | 277 | .minFrequency = 139000000, |
| 278 | .maxFrequency = 1139000000, |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 279 | .minSymbolRate = 45, |
| 280 | .maxSymbolRate = 1145, |
| 281 | .acquireRange = 30, |
| 282 | .exclusiveGroupId = 57, |
| 283 | .statusCaps = mFrontendStatusCaps[in_frontendId], |
| 284 | .frontendCaps = mFrontendCaps[in_frontendId], |
| 285 | }; |
| 286 | |
| 287 | return ::ndk::ScopedAStatus::ok(); |
| 288 | } |
| 289 | |
| 290 | ::ndk::ScopedAStatus Tuner::getLnbIds(std::vector<int32_t>* _aidl_return) { |
| 291 | ALOGV("%s", __FUNCTION__); |
| 292 | |
| 293 | _aidl_return->resize(mLnbs.size()); |
| 294 | for (int i = 0; i < mLnbs.size(); i++) { |
| 295 | (*_aidl_return)[i] = mLnbs[i]->getId(); |
| 296 | } |
| 297 | |
| 298 | return ::ndk::ScopedAStatus::ok(); |
| 299 | } |
| 300 | |
| 301 | ::ndk::ScopedAStatus Tuner::openLnbById(int32_t in_lnbId, std::shared_ptr<ILnb>* _aidl_return) { |
| 302 | ALOGV("%s", __FUNCTION__); |
| 303 | |
| 304 | if (in_lnbId >= mLnbs.size()) { |
| 305 | *_aidl_return = nullptr; |
Hongguang | e423acd | 2021-07-27 16:56:47 -0700 | [diff] [blame] | 306 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 307 | static_cast<int32_t>(Result::INVALID_ARGUMENT)); |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | *_aidl_return = mLnbs[in_lnbId]; |
| 311 | return ::ndk::ScopedAStatus::ok(); |
| 312 | } |
| 313 | |
| 314 | std::shared_ptr<Frontend> Tuner::getFrontendById(int32_t frontendId) { |
| 315 | ALOGV("%s", __FUNCTION__); |
| 316 | |
| 317 | return mFrontends[frontendId]; |
| 318 | } |
| 319 | |
| 320 | ::ndk::ScopedAStatus Tuner::openLnbByName(const std::string& /* in_lnbName */, |
| 321 | std::vector<int32_t>* out_lnbId, |
| 322 | std::shared_ptr<ILnb>* _aidl_return) { |
| 323 | ALOGV("%s", __FUNCTION__); |
| 324 | |
| 325 | out_lnbId->push_back(1234); |
| 326 | *_aidl_return = ndk::SharedRefBase::make<Lnb>(); |
| 327 | |
| 328 | return ::ndk::ScopedAStatus::ok(); |
| 329 | } |
| 330 | |
Hongguang | fcedda0 | 2021-12-13 17:08:02 -0800 | [diff] [blame] | 331 | ::ndk::ScopedAStatus Tuner::setLna(bool /* in_bEnable */) { |
| 332 | ALOGV("%s", __FUNCTION__); |
| 333 | |
| 334 | return ::ndk::ScopedAStatus::ok(); |
| 335 | } |
| 336 | |
Hongguang | 5766ddf | 2021-12-23 11:40:37 -0800 | [diff] [blame^] | 337 | ::ndk::ScopedAStatus Tuner::setMaxNumberOfFrontends(FrontendType in_frontendType, |
| 338 | int32_t in_maxNumber) { |
| 339 | ALOGV("%s", __FUNCTION__); |
| 340 | |
| 341 | // In the default implementation, every type only has one frontend. |
| 342 | if (in_maxNumber < 0 || in_maxNumber > 1) { |
| 343 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 344 | static_cast<int32_t>(Result::INVALID_ARGUMENT)); |
| 345 | } |
| 346 | mMaxUsableFrontends[in_frontendType] = in_maxNumber; |
| 347 | return ::ndk::ScopedAStatus::ok(); |
| 348 | } |
| 349 | |
| 350 | ::ndk::ScopedAStatus Tuner::getMaxNumberOfFrontends(FrontendType in_frontendType, |
| 351 | int32_t* _aidl_return) { |
| 352 | *_aidl_return = mMaxUsableFrontends[in_frontendType]; |
| 353 | return ::ndk::ScopedAStatus::ok(); |
| 354 | } |
| 355 | |
Hongguang | 2ecfc39 | 2021-11-23 10:29:15 -0800 | [diff] [blame] | 356 | binder_status_t Tuner::dump(int fd, const char** args, uint32_t numArgs) { |
| 357 | ALOGV("%s", __FUNCTION__); |
| 358 | { |
| 359 | dprintf(fd, "Frontends:\n"); |
| 360 | for (int i = 0; i < mFrontendSize; i++) { |
| 361 | mFrontends[i]->dump(fd, args, numArgs); |
| 362 | for (int j = 0; j < mFrontendStatusCaps[i].size(); j++) { |
| 363 | dprintf(fd, " statusCap: %d\n", mFrontendStatusCaps[i][j]); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | { |
| 368 | dprintf(fd, "Demuxs:\n"); |
| 369 | map<int32_t, std::shared_ptr<Demux>>::iterator it; |
| 370 | for (it = mDemuxes.begin(); it != mDemuxes.end(); it++) { |
| 371 | it->second->dump(fd, args, numArgs); |
| 372 | } |
| 373 | } |
| 374 | { |
| 375 | dprintf(fd, "Lnbs:\n"); |
| 376 | for (int i = 0; i < mLnbs.size(); i++) { |
| 377 | mLnbs[i]->dump(fd, args, numArgs); |
| 378 | } |
| 379 | } |
| 380 | return STATUS_OK; |
| 381 | } |
| 382 | |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 383 | void Tuner::setFrontendAsDemuxSource(int32_t frontendId, int32_t demuxId) { |
| 384 | mFrontendToDemux[frontendId] = demuxId; |
| 385 | if (mFrontends[frontendId] != nullptr && mFrontends[frontendId]->isLocked()) { |
| 386 | mDemuxes[demuxId]->startFrontendInputLoop(); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | void Tuner::removeDemux(int32_t demuxId) { |
| 391 | map<int32_t, int32_t>::iterator it; |
| 392 | for (it = mFrontendToDemux.begin(); it != mFrontendToDemux.end(); it++) { |
| 393 | if (it->second == demuxId) { |
| 394 | it = mFrontendToDemux.erase(it); |
| 395 | break; |
| 396 | } |
| 397 | } |
| 398 | mDemuxes.erase(demuxId); |
| 399 | } |
| 400 | |
| 401 | void Tuner::removeFrontend(int32_t frontendId) { |
Hongguang | 2ecfc39 | 2021-11-23 10:29:15 -0800 | [diff] [blame] | 402 | map<int32_t, int32_t>::iterator it = mFrontendToDemux.find(frontendId); |
| 403 | if (it != mFrontendToDemux.end()) { |
| 404 | mDemuxes.erase(it->second); |
| 405 | } |
Hongguang | 4092f2f | 2021-07-08 18:49:12 -0700 | [diff] [blame] | 406 | mFrontendToDemux.erase(frontendId); |
| 407 | } |
| 408 | |
| 409 | void Tuner::frontendStopTune(int32_t frontendId) { |
| 410 | map<int32_t, int32_t>::iterator it = mFrontendToDemux.find(frontendId); |
| 411 | int32_t demuxId; |
| 412 | if (it != mFrontendToDemux.end()) { |
| 413 | demuxId = it->second; |
| 414 | mDemuxes[demuxId]->stopFrontendInput(); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | void Tuner::frontendStartTune(int32_t frontendId) { |
| 419 | map<int32_t, int32_t>::iterator it = mFrontendToDemux.find(frontendId); |
| 420 | int32_t demuxId; |
| 421 | if (it != mFrontendToDemux.end()) { |
| 422 | demuxId = it->second; |
| 423 | mDemuxes[demuxId]->startFrontendInputLoop(); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | } // namespace tuner |
| 428 | } // namespace tv |
| 429 | } // namespace hardware |
| 430 | } // namespace android |
| 431 | } // namespace aidl |