Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 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 | #define LOG_TAG "android.hardware.tv.tuner@1.1-Frontend" |
| 18 | |
| 19 | #include "Frontend.h" |
Amy Zhang | 19ed17b | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 20 | #include <android/hardware/tv/tuner/1.1/IFrontendCallback.h> |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 21 | #include <utils/Log.h> |
| 22 | |
| 23 | namespace android { |
| 24 | namespace hardware { |
| 25 | namespace tv { |
| 26 | namespace tuner { |
| 27 | namespace V1_0 { |
| 28 | namespace implementation { |
| 29 | |
| 30 | Frontend::Frontend(FrontendType type, FrontendId id, sp<Tuner> tuner) { |
| 31 | mType = type; |
| 32 | mId = id; |
| 33 | mTunerService = tuner; |
| 34 | // Init callback to nullptr |
| 35 | mCallback = nullptr; |
| 36 | } |
| 37 | |
| 38 | Frontend::~Frontend() {} |
| 39 | |
| 40 | Return<Result> Frontend::close() { |
| 41 | ALOGV("%s", __FUNCTION__); |
| 42 | // Reset callback |
| 43 | mCallback = nullptr; |
| 44 | mIsLocked = false; |
Amy Zhang | 80cb960 | 2020-07-15 13:06:39 -0700 | [diff] [blame] | 45 | mTunerService->removeFrontend(mId); |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 46 | |
| 47 | return Result::SUCCESS; |
| 48 | } |
| 49 | |
| 50 | Return<Result> Frontend::setCallback(const sp<IFrontendCallback>& callback) { |
| 51 | ALOGV("%s", __FUNCTION__); |
| 52 | if (callback == nullptr) { |
| 53 | ALOGW("[ WARN ] Set Frontend callback with nullptr"); |
| 54 | return Result::INVALID_ARGUMENT; |
| 55 | } |
| 56 | |
| 57 | mCallback = callback; |
| 58 | return Result::SUCCESS; |
| 59 | } |
| 60 | |
| 61 | Return<Result> Frontend::tune(const FrontendSettings& /* settings */) { |
| 62 | ALOGV("%s", __FUNCTION__); |
| 63 | if (mCallback == nullptr) { |
| 64 | ALOGW("[ WARN ] Frontend callback is not set when tune"); |
| 65 | return Result::INVALID_STATE; |
| 66 | } |
| 67 | |
| 68 | mTunerService->frontendStartTune(mId); |
| 69 | mCallback->onEvent(FrontendEventType::LOCKED); |
| 70 | mIsLocked = true; |
| 71 | return Result::SUCCESS; |
| 72 | } |
| 73 | |
Amy Zhang | 3ea25a6 | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 74 | Return<Result> Frontend::tune_1_1(const FrontendSettings& settings, |
Amy Zhang | bc15b59 | 2020-09-25 15:35:55 -0700 | [diff] [blame] | 75 | const V1_1::FrontendSettingsExt1_1& /*settingsExt1_1*/) { |
Amy Zhang | 3ea25a6 | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 76 | ALOGV("%s", __FUNCTION__); |
| 77 | return tune(settings); |
| 78 | } |
| 79 | |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 80 | Return<Result> Frontend::stopTune() { |
| 81 | ALOGV("%s", __FUNCTION__); |
| 82 | |
| 83 | mTunerService->frontendStopTune(mId); |
| 84 | mIsLocked = false; |
| 85 | |
| 86 | return Result::SUCCESS; |
| 87 | } |
| 88 | |
| 89 | Return<Result> Frontend::scan(const FrontendSettings& settings, FrontendScanType type) { |
| 90 | ALOGV("%s", __FUNCTION__); |
| 91 | |
| 92 | if (mType == FrontendType::ATSC) { |
| 93 | FrontendScanMessage msg; |
| 94 | msg.isLocked(true); |
| 95 | mCallback->onScanMessage(FrontendScanMessageType::LOCKED, msg); |
| 96 | mIsLocked = true; |
| 97 | return Result::SUCCESS; |
| 98 | } |
| 99 | if (mType != FrontendType::DVBT) { |
| 100 | return Result::UNAVAILABLE; |
| 101 | } |
| 102 | |
| 103 | FrontendScanMessage msg; |
| 104 | |
| 105 | if (mIsLocked) { |
| 106 | msg.isEnd(true); |
| 107 | mCallback->onScanMessage(FrontendScanMessageType::END, msg); |
| 108 | return Result::SUCCESS; |
| 109 | } |
| 110 | |
| 111 | uint32_t frequency = settings.dvbt().frequency; |
| 112 | if (type == FrontendScanType::SCAN_BLIND) { |
| 113 | frequency += 100; |
| 114 | } |
| 115 | msg.frequencies({frequency}); |
| 116 | mCallback->onScanMessage(FrontendScanMessageType::FREQUENCY, msg); |
| 117 | msg.isLocked(true); |
| 118 | mCallback->onScanMessage(FrontendScanMessageType::LOCKED, msg); |
| 119 | mIsLocked = true; |
| 120 | |
Amy Zhang | 19ed17b | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 121 | sp<V1_1::IFrontendCallback> frontendCallback_v1_1 = |
| 122 | V1_1::IFrontendCallback::castFrom(mCallback); |
| 123 | if (frontendCallback_v1_1 != NULL) { |
| 124 | V1_1::FrontendScanMessageExt1_1 msg; |
Amy Zhang | 7ec2b70 | 2020-10-05 18:07:20 -0700 | [diff] [blame] | 125 | msg.modulation().dvbc(FrontendDvbcModulation::MOD_16QAM); |
Amy Zhang | 19ed17b | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 126 | frontendCallback_v1_1->onScanMessageExt1_1(V1_1::FrontendScanMessageTypeExt1_1::MODULATION, |
| 127 | msg); |
Amy Zhang | 7ec2b70 | 2020-10-05 18:07:20 -0700 | [diff] [blame] | 128 | msg.isHighPriority(true); |
| 129 | frontendCallback_v1_1->onScanMessageExt1_1( |
| 130 | V1_1::FrontendScanMessageTypeExt1_1::HIGH_PRIORITY, msg); |
Amy Zhang | 19ed17b | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 131 | } else { |
| 132 | ALOGD("[Filter] Couldn't cast to V1_1 IFrontendCallback"); |
| 133 | } |
| 134 | |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 135 | return Result::SUCCESS; |
| 136 | } |
| 137 | |
Amy Zhang | 3ea25a6 | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 138 | Return<Result> Frontend::scan_1_1(const FrontendSettings& settings, FrontendScanType type, |
Amy Zhang | bc15b59 | 2020-09-25 15:35:55 -0700 | [diff] [blame] | 139 | const V1_1::FrontendSettingsExt1_1& /*settingsExt1_1*/) { |
Amy Zhang | 3ea25a6 | 2020-08-04 10:23:52 -0700 | [diff] [blame] | 140 | ALOGV("%s", __FUNCTION__); |
| 141 | return scan(settings, type); |
| 142 | } |
| 143 | |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 144 | Return<Result> Frontend::stopScan() { |
| 145 | ALOGV("%s", __FUNCTION__); |
| 146 | |
| 147 | mIsLocked = false; |
| 148 | return Result::SUCCESS; |
| 149 | } |
| 150 | |
| 151 | Return<void> Frontend::getStatus(const hidl_vec<FrontendStatusType>& statusTypes, |
| 152 | getStatus_cb _hidl_cb) { |
| 153 | ALOGV("%s", __FUNCTION__); |
| 154 | |
| 155 | vector<FrontendStatus> statuses; |
| 156 | for (int i = 0; i < statusTypes.size(); i++) { |
| 157 | FrontendStatusType type = statusTypes[i]; |
| 158 | FrontendStatus status; |
| 159 | // assign randomly selected values for testing. |
| 160 | switch (type) { |
| 161 | case FrontendStatusType::DEMOD_LOCK: { |
| 162 | status.isDemodLocked(true); |
| 163 | break; |
| 164 | } |
| 165 | case FrontendStatusType::SNR: { |
| 166 | status.snr(221); |
| 167 | break; |
| 168 | } |
| 169 | case FrontendStatusType::BER: { |
| 170 | status.ber(1); |
| 171 | break; |
| 172 | } |
| 173 | case FrontendStatusType::PER: { |
| 174 | status.per(2); |
| 175 | break; |
| 176 | } |
| 177 | case FrontendStatusType::PRE_BER: { |
| 178 | status.preBer(3); |
| 179 | break; |
| 180 | } |
| 181 | case FrontendStatusType::SIGNAL_QUALITY: { |
| 182 | status.signalQuality(4); |
| 183 | break; |
| 184 | } |
| 185 | case FrontendStatusType::SIGNAL_STRENGTH: { |
| 186 | status.signalStrength(5); |
| 187 | break; |
| 188 | } |
| 189 | case FrontendStatusType::SYMBOL_RATE: { |
| 190 | status.symbolRate(6); |
| 191 | break; |
| 192 | } |
| 193 | case FrontendStatusType::FEC: { |
| 194 | status.innerFec(FrontendInnerFec::FEC_2_9); // value = 1 << 7 |
| 195 | break; |
| 196 | } |
| 197 | case FrontendStatusType::MODULATION: { |
| 198 | FrontendModulationStatus modulationStatus; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 199 | switch (mType) { |
| 200 | case FrontendType::ISDBS: { |
| 201 | modulationStatus.isdbs( |
| 202 | FrontendIsdbsModulation::MOD_BPSK); // value = 1 << 1 |
| 203 | status.modulation(modulationStatus); |
| 204 | break; |
| 205 | } |
| 206 | case FrontendType::DVBC: { |
| 207 | modulationStatus.dvbc(FrontendDvbcModulation::MOD_16QAM); // value = 1 << 1 |
| 208 | status.modulation(modulationStatus); |
| 209 | break; |
| 210 | } |
| 211 | case FrontendType::DVBS: { |
| 212 | modulationStatus.dvbs(FrontendDvbsModulation::MOD_QPSK); // value = 1 << 1 |
| 213 | status.modulation(modulationStatus); |
| 214 | break; |
| 215 | } |
| 216 | case FrontendType::ISDBS3: { |
| 217 | modulationStatus.isdbs3( |
| 218 | FrontendIsdbs3Modulation::MOD_BPSK); // value = 1 << 1 |
| 219 | status.modulation(modulationStatus); |
| 220 | break; |
| 221 | } |
| 222 | case FrontendType::ISDBT: { |
| 223 | modulationStatus.isdbt( |
| 224 | FrontendIsdbtModulation::MOD_DQPSK); // value = 1 << 1 |
| 225 | status.modulation(modulationStatus); |
| 226 | break; |
| 227 | } |
| 228 | default: |
| 229 | break; |
| 230 | } |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 231 | break; |
| 232 | } |
| 233 | case FrontendStatusType::SPECTRAL: { |
| 234 | status.inversion(FrontendDvbcSpectralInversion::NORMAL); |
| 235 | break; |
| 236 | } |
| 237 | case FrontendStatusType::LNB_VOLTAGE: { |
| 238 | status.lnbVoltage(LnbVoltage::VOLTAGE_5V); |
| 239 | break; |
| 240 | } |
| 241 | case FrontendStatusType::PLP_ID: { |
| 242 | status.plpId(101); // type uint8_t |
| 243 | break; |
| 244 | } |
| 245 | case FrontendStatusType::EWBS: { |
| 246 | status.isEWBS(false); |
| 247 | break; |
| 248 | } |
| 249 | case FrontendStatusType::AGC: { |
| 250 | status.agc(7); |
| 251 | break; |
| 252 | } |
| 253 | case FrontendStatusType::LNA: { |
| 254 | status.isLnaOn(false); |
| 255 | break; |
| 256 | } |
| 257 | case FrontendStatusType::LAYER_ERROR: { |
| 258 | vector<bool> v = {false, true, true}; |
| 259 | status.isLayerError(v); |
| 260 | break; |
| 261 | } |
| 262 | case FrontendStatusType::MER: { |
| 263 | status.mer(8); |
| 264 | break; |
| 265 | } |
| 266 | case FrontendStatusType::FREQ_OFFSET: { |
| 267 | status.freqOffset(9); |
| 268 | break; |
| 269 | } |
| 270 | case FrontendStatusType::HIERARCHY: { |
| 271 | status.hierarchy(FrontendDvbtHierarchy::HIERARCHY_1_NATIVE); |
| 272 | break; |
| 273 | } |
| 274 | case FrontendStatusType::RF_LOCK: { |
| 275 | status.isRfLocked(false); |
| 276 | break; |
| 277 | } |
| 278 | case FrontendStatusType::ATSC3_PLP_INFO: { |
| 279 | vector<FrontendStatusAtsc3PlpInfo> v; |
| 280 | FrontendStatusAtsc3PlpInfo info1{ |
| 281 | .plpId = 3, |
| 282 | .isLocked = false, |
| 283 | .uec = 313, |
| 284 | }; |
| 285 | FrontendStatusAtsc3PlpInfo info2{ |
| 286 | .plpId = 5, |
| 287 | .isLocked = true, |
| 288 | .uec = 515, |
| 289 | }; |
| 290 | v.push_back(info1); |
| 291 | v.push_back(info2); |
| 292 | status.plpInfo(v); |
| 293 | break; |
| 294 | } |
| 295 | default: { |
| 296 | continue; |
| 297 | } |
| 298 | } |
| 299 | statuses.push_back(status); |
| 300 | } |
| 301 | _hidl_cb(Result::SUCCESS, statuses); |
| 302 | |
| 303 | return Void(); |
| 304 | } |
| 305 | |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 306 | Return<void> Frontend::getStatusExt1_1(const hidl_vec<V1_1::FrontendStatusTypeExt1_1>& statusTypes, |
| 307 | V1_1::IFrontend::getStatusExt1_1_cb _hidl_cb) { |
| 308 | ALOGV("%s", __FUNCTION__); |
| 309 | |
| 310 | vector<V1_1::FrontendStatusExt1_1> statuses; |
| 311 | for (int i = 0; i < statusTypes.size(); i++) { |
| 312 | V1_1::FrontendStatusTypeExt1_1 type = statusTypes[i]; |
| 313 | V1_1::FrontendStatusExt1_1 status; |
Amy Zhang | f2354c6 | 2021-02-08 19:58:04 -0800 | [diff] [blame] | 314 | |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 315 | switch (type) { |
| 316 | case V1_1::FrontendStatusTypeExt1_1::MODULATIONS: { |
| 317 | vector<V1_1::FrontendModulation> modulations; |
| 318 | V1_1::FrontendModulation modulation; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 319 | switch ((int)mType) { |
| 320 | case (int)FrontendType::ISDBS: { |
| 321 | modulation.isdbs(FrontendIsdbsModulation::MOD_BPSK); // value = 1 << 1 |
| 322 | modulations.push_back(modulation); |
| 323 | status.modulations(modulations); |
| 324 | break; |
| 325 | } |
| 326 | case (int)FrontendType::DVBC: { |
| 327 | modulation.dvbc(FrontendDvbcModulation::MOD_16QAM); // value = 1 << 1 |
| 328 | modulations.push_back(modulation); |
| 329 | status.modulations(modulations); |
| 330 | break; |
| 331 | } |
| 332 | case (int)FrontendType::DVBS: { |
| 333 | modulation.dvbs(FrontendDvbsModulation::MOD_QPSK); // value = 1 << 1 |
| 334 | modulations.push_back(modulation); |
| 335 | status.modulations(modulations); |
| 336 | break; |
| 337 | } |
| 338 | case (int)FrontendType::DVBT: { |
| 339 | // value = 1 << 16 |
| 340 | modulation.dvbt(V1_1::FrontendDvbtConstellation::CONSTELLATION_16QAM_R); |
| 341 | modulations.push_back(modulation); |
| 342 | status.modulations(modulations); |
| 343 | break; |
| 344 | } |
| 345 | case (int)FrontendType::ISDBS3: { |
| 346 | modulation.isdbs3(FrontendIsdbs3Modulation::MOD_BPSK); // value = 1 << 1 |
| 347 | modulations.push_back(modulation); |
| 348 | status.modulations(modulations); |
| 349 | break; |
| 350 | } |
| 351 | case (int)FrontendType::ISDBT: { |
| 352 | modulation.isdbt(FrontendIsdbtModulation::MOD_DQPSK); // value = 1 << 1 |
| 353 | modulations.push_back(modulation); |
| 354 | status.modulations(modulations); |
| 355 | break; |
| 356 | } |
| 357 | case (int)FrontendType::ATSC: { |
| 358 | modulation.atsc(FrontendAtscModulation::MOD_8VSB); // value = 1 << 2 |
| 359 | modulations.push_back(modulation); |
| 360 | status.modulations(modulations); |
| 361 | break; |
| 362 | } |
| 363 | case (int)FrontendType::ATSC3: { |
| 364 | modulation.atsc3(FrontendAtsc3Modulation::MOD_QPSK); // value = 1 << 1 |
| 365 | modulations.push_back(modulation); |
| 366 | status.modulations(modulations); |
| 367 | break; |
| 368 | } |
| 369 | case (int)V1_1::FrontendType::DTMB: { |
| 370 | // value = 1 << 1 |
| 371 | modulation.dtmb(V1_1::FrontendDtmbModulation::CONSTELLATION_4QAM); |
| 372 | modulations.push_back(modulation); |
| 373 | status.modulations(modulations); |
| 374 | break; |
| 375 | } |
| 376 | default: |
| 377 | break; |
| 378 | } |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 379 | break; |
| 380 | } |
| 381 | case V1_1::FrontendStatusTypeExt1_1::BERS: { |
| 382 | vector<uint32_t> bers = {1}; |
| 383 | status.bers(bers); |
| 384 | break; |
| 385 | } |
| 386 | case V1_1::FrontendStatusTypeExt1_1::CODERATES: { |
| 387 | // value = 1 << 39 |
| 388 | vector<V1_1::FrontendInnerFec> codeRates = {V1_1::FrontendInnerFec::FEC_6_15}; |
| 389 | status.codeRates(codeRates); |
| 390 | break; |
| 391 | } |
Amy Zhang | 7e669ce | 2020-10-20 16:41:30 -0700 | [diff] [blame] | 392 | case V1_1::FrontendStatusTypeExt1_1::BANDWIDTH: { |
| 393 | V1_1::FrontendBandwidth bandwidth; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 394 | switch ((int)mType) { |
| 395 | case (int)FrontendType::DVBC: { |
| 396 | // value = 1 << 1 |
| 397 | bandwidth.dvbc(V1_1::FrontendDvbcBandwidth::BANDWIDTH_6MHZ); |
| 398 | status.bandwidth(bandwidth); |
| 399 | break; |
| 400 | } |
| 401 | case (int)FrontendType::DVBT: { |
| 402 | // value = 1 << 1 |
| 403 | bandwidth.dvbt(FrontendDvbtBandwidth::BANDWIDTH_8MHZ); |
| 404 | status.bandwidth(bandwidth); |
| 405 | break; |
| 406 | } |
| 407 | case (int)FrontendType::ISDBT: { |
| 408 | bandwidth.isdbt(FrontendIsdbtBandwidth::BANDWIDTH_8MHZ); // value = 1 << 1 |
| 409 | status.bandwidth(bandwidth); |
| 410 | break; |
| 411 | } |
| 412 | case (int)FrontendType::ATSC3: { |
| 413 | bandwidth.atsc3(FrontendAtsc3Bandwidth::BANDWIDTH_6MHZ); // value = 1 << 1 |
| 414 | status.bandwidth(bandwidth); |
| 415 | break; |
| 416 | } |
| 417 | case (int)V1_1::FrontendType::DTMB: { |
| 418 | // value = 1 << 1 |
| 419 | bandwidth.dtmb(V1_1::FrontendDtmbBandwidth::BANDWIDTH_8MHZ); |
| 420 | status.bandwidth(bandwidth); |
| 421 | break; |
| 422 | } |
| 423 | default: |
| 424 | break; |
| 425 | } |
Amy Zhang | 7e669ce | 2020-10-20 16:41:30 -0700 | [diff] [blame] | 426 | break; |
| 427 | } |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 428 | case V1_1::FrontendStatusTypeExt1_1::GUARD_INTERVAL: { |
| 429 | V1_1::FrontendGuardInterval interval; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 430 | switch ((int)mType) { |
| 431 | case (int)FrontendType::DVBT: { |
| 432 | interval.dvbt(FrontendDvbtGuardInterval::INTERVAL_1_32); // value = 1 << 1 |
| 433 | status.interval(interval); |
| 434 | break; |
| 435 | } |
| 436 | case (int)FrontendType::ISDBT: { |
| 437 | interval.isdbt(FrontendDvbtGuardInterval::INTERVAL_1_32); // value = 1 << 1 |
| 438 | status.interval(interval); |
| 439 | break; |
| 440 | } |
| 441 | case (int)V1_1::FrontendType::DTMB: { |
| 442 | // value = 1 << 1 |
| 443 | interval.dtmb(V1_1::FrontendDtmbGuardInterval::PN_420_VARIOUS); |
| 444 | status.interval(interval); |
| 445 | break; |
| 446 | } |
| 447 | default: |
| 448 | break; |
| 449 | } |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 450 | break; |
| 451 | } |
| 452 | case V1_1::FrontendStatusTypeExt1_1::TRANSMISSION_MODE: { |
| 453 | V1_1::FrontendTransmissionMode transMode; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 454 | switch ((int)mType) { |
| 455 | case (int)FrontendType::DVBT: { |
| 456 | // value = 1 << 8 |
| 457 | transMode.dvbt(V1_1::FrontendDvbtTransmissionMode::MODE_16K_E); |
| 458 | status.transmissionMode(transMode); |
| 459 | break; |
| 460 | } |
| 461 | case (int)FrontendType::ISDBT: { |
| 462 | transMode.isdbt(FrontendIsdbtMode::MODE_1); // value = 1 << 1 |
| 463 | status.transmissionMode(transMode); |
| 464 | break; |
| 465 | } |
| 466 | case (int)V1_1::FrontendType::DTMB: { |
| 467 | transMode.dtmb(V1_1::FrontendDtmbTransmissionMode::C1); // value = 1 << 1 |
| 468 | status.transmissionMode(transMode); |
| 469 | break; |
| 470 | } |
| 471 | default: |
| 472 | break; |
| 473 | } |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 474 | break; |
| 475 | } |
| 476 | case V1_1::FrontendStatusTypeExt1_1::UEC: { |
| 477 | status.uec(4); |
| 478 | break; |
| 479 | } |
| 480 | case V1_1::FrontendStatusTypeExt1_1::T2_SYSTEM_ID: { |
| 481 | status.systemId(5); |
| 482 | break; |
| 483 | } |
| 484 | case V1_1::FrontendStatusTypeExt1_1::INTERLEAVINGS: { |
| 485 | V1_1::FrontendInterleaveMode interleave; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 486 | switch ((int)mType) { |
| 487 | case (int)FrontendType::DVBC: { |
| 488 | // value = 1 << 1 |
| 489 | interleave.dvbc( |
| 490 | V1_1::FrontendCableTimeInterleaveMode::INTERLEAVING_128_1_0); |
| 491 | vector<V1_1::FrontendInterleaveMode> interleaving = {interleave}; |
| 492 | status.interleaving(interleaving); |
| 493 | break; |
| 494 | } |
| 495 | case (int)FrontendType::ATSC3: { |
| 496 | // value = 1 << 1 |
| 497 | interleave.atsc3(FrontendAtsc3TimeInterleaveMode::CTI); |
| 498 | vector<V1_1::FrontendInterleaveMode> interleaving = {interleave}; |
| 499 | status.interleaving(interleaving); |
| 500 | break; |
| 501 | } |
| 502 | case (int)V1_1::FrontendType::DTMB: { |
| 503 | // value = 1 << 1 |
| 504 | interleave.dtmb(V1_1::FrontendDtmbTimeInterleaveMode::TIMER_INT_240); |
| 505 | vector<V1_1::FrontendInterleaveMode> interleaving = {interleave}; |
| 506 | status.interleaving(interleaving); |
| 507 | break; |
| 508 | } |
| 509 | default: |
| 510 | break; |
| 511 | } |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 512 | break; |
| 513 | } |
| 514 | case V1_1::FrontendStatusTypeExt1_1::ISDBT_SEGMENTS: { |
| 515 | vector<uint8_t> segments = {2, 3}; |
| 516 | status.isdbtSegment(segments); |
| 517 | break; |
| 518 | } |
| 519 | case V1_1::FrontendStatusTypeExt1_1::TS_DATA_RATES: { |
| 520 | vector<uint32_t> dataRates = {4, 5}; |
| 521 | status.tsDataRate(dataRates); |
| 522 | break; |
| 523 | } |
Amy Zhang | 7e669ce | 2020-10-20 16:41:30 -0700 | [diff] [blame] | 524 | case V1_1::FrontendStatusTypeExt1_1::ROLL_OFF: { |
| 525 | V1_1::FrontendRollOff rollOff; |
Amy Zhang | 7394e62 | 2021-02-23 22:29:48 -0800 | [diff] [blame^] | 526 | switch (mType) { |
| 527 | case FrontendType::DVBS: { |
| 528 | // value = 1 |
| 529 | rollOff.dvbs(FrontendDvbsRolloff::ROLLOFF_0_35); |
| 530 | status.rollOff(rollOff); |
| 531 | break; |
| 532 | } |
| 533 | case FrontendType::ISDBS: { |
| 534 | // value = 1 |
| 535 | rollOff.isdbs(FrontendIsdbsRolloff::ROLLOFF_0_35); |
| 536 | status.rollOff(rollOff); |
| 537 | break; |
| 538 | } |
| 539 | case FrontendType::ISDBS3: { |
| 540 | // value = 1 |
| 541 | rollOff.isdbs3(FrontendIsdbs3Rolloff::ROLLOFF_0_03); |
| 542 | status.rollOff(rollOff); |
| 543 | break; |
| 544 | } |
| 545 | default: |
| 546 | break; |
| 547 | } |
Amy Zhang | 7e669ce | 2020-10-20 16:41:30 -0700 | [diff] [blame] | 548 | break; |
| 549 | } |
| 550 | case V1_1::FrontendStatusTypeExt1_1::IS_MISO: { |
| 551 | status.isMiso(true); |
| 552 | break; |
| 553 | } |
| 554 | case V1_1::FrontendStatusTypeExt1_1::IS_LINEAR: { |
| 555 | status.isLinear(true); |
| 556 | break; |
| 557 | } |
| 558 | case V1_1::FrontendStatusTypeExt1_1::IS_SHORT_FRAMES: { |
| 559 | status.isShortFrames(true); |
| 560 | break; |
| 561 | } |
Amy Zhang | 422bb11 | 2020-08-12 15:21:44 -0700 | [diff] [blame] | 562 | default: { |
| 563 | continue; |
| 564 | } |
| 565 | } |
| 566 | statuses.push_back(status); |
| 567 | } |
| 568 | _hidl_cb(Result::SUCCESS, statuses); |
| 569 | |
| 570 | return Void(); |
| 571 | } |
| 572 | |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 573 | Return<Result> Frontend::setLna(bool /* bEnable */) { |
| 574 | ALOGV("%s", __FUNCTION__); |
| 575 | |
| 576 | return Result::SUCCESS; |
| 577 | } |
| 578 | |
| 579 | Return<Result> Frontend::setLnb(uint32_t /* lnb */) { |
| 580 | ALOGV("%s", __FUNCTION__); |
| 581 | if (!supportsSatellite()) { |
| 582 | return Result::INVALID_STATE; |
| 583 | } |
| 584 | return Result::SUCCESS; |
| 585 | } |
| 586 | |
Amy Zhang | e8a5737 | 2020-10-07 12:24:48 -0700 | [diff] [blame] | 587 | Return<void> Frontend::linkCiCam(uint32_t ciCamId, linkCiCam_cb _hidl_cb) { |
Amy Zhang | 17f8eac | 2020-08-17 16:52:13 -0700 | [diff] [blame] | 588 | ALOGV("%s", __FUNCTION__); |
| 589 | |
| 590 | mCiCamId = ciCamId; |
Amy Zhang | e8a5737 | 2020-10-07 12:24:48 -0700 | [diff] [blame] | 591 | _hidl_cb(Result::SUCCESS, 0 /*ltsId*/); |
| 592 | |
| 593 | return Void(); |
| 594 | } |
| 595 | |
| 596 | Return<Result> Frontend::unlinkCiCam(uint32_t /*ciCamId*/) { |
| 597 | ALOGV("%s", __FUNCTION__); |
| 598 | |
| 599 | mCiCamId = -1; |
Amy Zhang | 17f8eac | 2020-08-17 16:52:13 -0700 | [diff] [blame] | 600 | |
| 601 | return Result::SUCCESS; |
| 602 | } |
| 603 | |
Amy Zhang | bb94eeb | 2020-07-09 22:48:04 -0700 | [diff] [blame] | 604 | FrontendType Frontend::getFrontendType() { |
| 605 | return mType; |
| 606 | } |
| 607 | |
| 608 | FrontendId Frontend::getFrontendId() { |
| 609 | return mId; |
| 610 | } |
| 611 | |
| 612 | bool Frontend::supportsSatellite() { |
| 613 | return mType == FrontendType::DVBS || mType == FrontendType::ISDBS || |
| 614 | mType == FrontendType::ISDBS3; |
| 615 | } |
| 616 | |
| 617 | bool Frontend::isLocked() { |
| 618 | return mIsLocked; |
| 619 | } |
| 620 | } // namespace implementation |
| 621 | } // namespace V1_0 |
| 622 | } // namespace tuner |
| 623 | } // namespace tv |
| 624 | } // namespace hardware |
| 625 | } // namespace android |