Hongguang | 093c5f3 | 2021-08-09 19:46:34 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 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 "TunerHidlService" |
| 19 | |
| 20 | #include "TunerHidlService.h" |
| 21 | |
| 22 | #include <aidl/android/hardware/tv/tuner/Result.h> |
| 23 | #include <android/binder_manager.h> |
| 24 | #include <utils/Log.h> |
| 25 | |
| 26 | #include "TunerHelper.h" |
| 27 | #include "TunerHidlDemux.h" |
| 28 | #include "TunerHidlDescrambler.h" |
| 29 | #include "TunerHidlFrontend.h" |
| 30 | #include "TunerHidlLnb.h" |
| 31 | |
| 32 | using ::aidl::android::hardware::tv::tuner::FrontendAnalogCapabilities; |
| 33 | using ::aidl::android::hardware::tv::tuner::FrontendAtsc3Capabilities; |
| 34 | using ::aidl::android::hardware::tv::tuner::FrontendAtscCapabilities; |
| 35 | using ::aidl::android::hardware::tv::tuner::FrontendCapabilities; |
| 36 | using ::aidl::android::hardware::tv::tuner::FrontendDtmbCapabilities; |
| 37 | using ::aidl::android::hardware::tv::tuner::FrontendDvbcCapabilities; |
| 38 | using ::aidl::android::hardware::tv::tuner::FrontendDvbsCapabilities; |
| 39 | using ::aidl::android::hardware::tv::tuner::FrontendDvbtCapabilities; |
| 40 | using ::aidl::android::hardware::tv::tuner::FrontendIsdbs3Capabilities; |
| 41 | using ::aidl::android::hardware::tv::tuner::FrontendIsdbsCapabilities; |
| 42 | using ::aidl::android::hardware::tv::tuner::FrontendIsdbtCapabilities; |
| 43 | using ::aidl::android::hardware::tv::tuner::FrontendType; |
| 44 | using ::aidl::android::hardware::tv::tuner::Result; |
| 45 | using ::aidl::android::media::tv::tunerresourcemanager::TunerFrontendInfo; |
| 46 | using ::android::hardware::hidl_vec; |
| 47 | |
| 48 | using HidlFrontendId = ::android::hardware::tv::tuner::V1_0::FrontendId; |
| 49 | using HidlLnbId = ::android::hardware::tv::tuner::V1_0::LnbId; |
| 50 | using HidlFrontendType = ::android::hardware::tv::tuner::V1_1::FrontendType; |
| 51 | |
| 52 | using namespace std; |
| 53 | |
| 54 | namespace aidl { |
| 55 | namespace android { |
| 56 | namespace media { |
| 57 | namespace tv { |
| 58 | namespace tuner { |
| 59 | |
| 60 | TunerHidlService::TunerHidlService() { |
| 61 | if (!TunerHelper::checkTunerFeature()) { |
| 62 | ALOGD("Device doesn't have tuner hardware."); |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | updateTunerResources(); |
| 67 | } |
| 68 | |
| 69 | TunerHidlService::~TunerHidlService() {} |
| 70 | |
| 71 | binder_status_t TunerHidlService::instantiate() { |
| 72 | if (HidlITuner::getService() == nullptr) { |
| 73 | ALOGD("Failed to get ITuner HIDL HAL"); |
| 74 | return STATUS_NAME_NOT_FOUND; |
| 75 | } |
| 76 | |
| 77 | shared_ptr<TunerHidlService> service = ::ndk::SharedRefBase::make<TunerHidlService>(); |
| 78 | return AServiceManager_addService(service->asBinder().get(), getServiceName()); |
| 79 | } |
| 80 | |
| 81 | bool TunerHidlService::hasITuner() { |
| 82 | ALOGV("hasITuner"); |
| 83 | if (mTuner != nullptr) { |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | mTuner = HidlITuner::getService(); |
| 88 | if (mTuner == nullptr) { |
| 89 | ALOGE("Failed to get ITuner service"); |
| 90 | return false; |
| 91 | } |
| 92 | mTunerVersion = TUNER_HAL_VERSION_1_0; |
| 93 | |
| 94 | mTuner_1_1 = ::android::hardware::tv::tuner::V1_1::ITuner::castFrom(mTuner); |
| 95 | if (mTuner_1_1 != nullptr) { |
| 96 | mTunerVersion = TUNER_HAL_VERSION_1_1; |
| 97 | } else { |
| 98 | ALOGD("Failed to get ITuner_1_1 service"); |
| 99 | } |
| 100 | |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | bool TunerHidlService::hasITuner_1_1() { |
| 105 | ALOGV("hasITuner_1_1"); |
| 106 | hasITuner(); |
| 107 | return (mTunerVersion == TUNER_HAL_VERSION_1_1); |
| 108 | } |
| 109 | |
| 110 | ::ndk::ScopedAStatus TunerHidlService::openDemux(int32_t /* in_demuxHandle */, |
| 111 | shared_ptr<ITunerDemux>* _aidl_return) { |
| 112 | ALOGV("openDemux"); |
| 113 | if (!hasITuner()) { |
| 114 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 115 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 116 | } |
| 117 | |
| 118 | HidlResult res; |
| 119 | uint32_t id; |
| 120 | sp<IDemux> demuxSp = nullptr; |
| 121 | mTuner->openDemux([&](HidlResult r, uint32_t demuxId, const sp<IDemux>& demux) { |
| 122 | demuxSp = demux; |
| 123 | id = demuxId; |
| 124 | res = r; |
| 125 | ALOGD("open demux, id = %d", demuxId); |
| 126 | }); |
| 127 | if (res == HidlResult::SUCCESS) { |
| 128 | *_aidl_return = ::ndk::SharedRefBase::make<TunerHidlDemux>(demuxSp, id); |
| 129 | return ::ndk::ScopedAStatus::ok(); |
| 130 | } |
| 131 | |
| 132 | ALOGW("open demux failed, res = %d", res); |
| 133 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res)); |
| 134 | } |
| 135 | |
| 136 | ::ndk::ScopedAStatus TunerHidlService::getDemuxCaps(DemuxCapabilities* _aidl_return) { |
| 137 | ALOGV("getDemuxCaps"); |
| 138 | if (!hasITuner()) { |
| 139 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 140 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 141 | } |
| 142 | |
| 143 | HidlResult res; |
| 144 | HidlDemuxCapabilities caps; |
| 145 | mTuner->getDemuxCaps([&](HidlResult r, const HidlDemuxCapabilities& demuxCaps) { |
| 146 | caps = demuxCaps; |
| 147 | res = r; |
| 148 | }); |
| 149 | if (res == HidlResult::SUCCESS) { |
| 150 | *_aidl_return = getAidlDemuxCaps(caps); |
| 151 | return ::ndk::ScopedAStatus::ok(); |
| 152 | } |
| 153 | |
| 154 | ALOGW("Get demux caps failed, res = %d", res); |
| 155 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res)); |
| 156 | } |
| 157 | |
| 158 | ::ndk::ScopedAStatus TunerHidlService::getFrontendIds(vector<int32_t>* ids) { |
| 159 | if (!hasITuner()) { |
| 160 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 161 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 162 | } |
| 163 | |
| 164 | hidl_vec<HidlFrontendId> feIds; |
| 165 | HidlResult res = getHidlFrontendIds(feIds); |
| 166 | if (res != HidlResult::SUCCESS) { |
| 167 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res)); |
| 168 | } |
| 169 | ids->resize(feIds.size()); |
| 170 | copy(feIds.begin(), feIds.end(), ids->begin()); |
| 171 | |
| 172 | return ::ndk::ScopedAStatus::ok(); |
| 173 | } |
| 174 | |
| 175 | ::ndk::ScopedAStatus TunerHidlService::getFrontendInfo(int32_t id, FrontendInfo* _aidl_return) { |
| 176 | if (!hasITuner()) { |
| 177 | ALOGE("ITuner service is not init."); |
| 178 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 179 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 180 | } |
| 181 | |
| 182 | HidlFrontendInfo info; |
| 183 | HidlResult res = getHidlFrontendInfo(id, info); |
| 184 | if (res != HidlResult::SUCCESS) { |
| 185 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res)); |
| 186 | } |
| 187 | |
| 188 | HidlFrontendDtmbCapabilities dtmbCaps; |
| 189 | if (static_cast<HidlFrontendType>(info.type) == HidlFrontendType::DTMB) { |
| 190 | if (!hasITuner_1_1()) { |
| 191 | ALOGE("ITuner_1_1 service is not init."); |
| 192 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 193 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 194 | } |
| 195 | |
| 196 | mTuner_1_1->getFrontendDtmbCapabilities( |
| 197 | id, [&](HidlResult r, const HidlFrontendDtmbCapabilities& caps) { |
| 198 | dtmbCaps = caps; |
| 199 | res = r; |
| 200 | }); |
| 201 | if (res != HidlResult::SUCCESS) { |
| 202 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(res)); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | *_aidl_return = getAidlFrontendInfo(info, dtmbCaps); |
| 207 | return ::ndk::ScopedAStatus::ok(); |
| 208 | } |
| 209 | |
| 210 | ::ndk::ScopedAStatus TunerHidlService::openFrontend(int32_t frontendHandle, |
| 211 | shared_ptr<ITunerFrontend>* _aidl_return) { |
| 212 | if (!hasITuner()) { |
| 213 | ALOGE("ITuner service is not init."); |
| 214 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 215 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 216 | } |
| 217 | |
| 218 | HidlResult status; |
| 219 | sp<HidlIFrontend> frontend; |
| 220 | int id = TunerHelper::getResourceIdFromHandle(frontendHandle, FRONTEND); |
| 221 | mTuner->openFrontendById(id, [&](HidlResult result, const sp<HidlIFrontend>& fe) { |
| 222 | frontend = fe; |
| 223 | status = result; |
| 224 | }); |
| 225 | if (status != HidlResult::SUCCESS) { |
| 226 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 227 | } |
| 228 | *_aidl_return = ::ndk::SharedRefBase::make<TunerHidlFrontend>(frontend, id); |
| 229 | return ::ndk::ScopedAStatus::ok(); |
| 230 | } |
| 231 | |
| 232 | ::ndk::ScopedAStatus TunerHidlService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) { |
| 233 | if (!hasITuner()) { |
| 234 | ALOGD("get ITuner failed"); |
| 235 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 236 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 237 | } |
| 238 | |
| 239 | HidlResult status; |
| 240 | sp<HidlILnb> lnb; |
| 241 | int id = TunerHelper::getResourceIdFromHandle(lnbHandle, LNB); |
| 242 | mTuner->openLnbById(id, [&](HidlResult result, const sp<HidlILnb>& lnbSp) { |
| 243 | lnb = lnbSp; |
| 244 | status = result; |
| 245 | }); |
| 246 | if (status != HidlResult::SUCCESS) { |
| 247 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 248 | } |
| 249 | |
| 250 | *_aidl_return = ::ndk::SharedRefBase::make<TunerHidlLnb>(lnb, id); |
| 251 | return ::ndk::ScopedAStatus::ok(); |
| 252 | } |
| 253 | |
| 254 | ::ndk::ScopedAStatus TunerHidlService::openLnbByName(const string& lnbName, |
| 255 | shared_ptr<ITunerLnb>* _aidl_return) { |
| 256 | if (!hasITuner()) { |
| 257 | ALOGE("get ITuner failed"); |
| 258 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 259 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 260 | } |
| 261 | |
| 262 | int lnbId; |
| 263 | HidlResult status; |
| 264 | sp<HidlILnb> lnb; |
| 265 | mTuner->openLnbByName(lnbName, [&](HidlResult r, HidlLnbId id, const sp<HidlILnb>& lnbSp) { |
| 266 | status = r; |
| 267 | lnb = lnbSp; |
| 268 | lnbId = static_cast<int32_t>(id); |
| 269 | }); |
| 270 | if (status != HidlResult::SUCCESS) { |
| 271 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 272 | } |
| 273 | |
| 274 | *_aidl_return = ::ndk::SharedRefBase::make<TunerHidlLnb>(lnb, lnbId); |
| 275 | return ::ndk::ScopedAStatus::ok(); |
| 276 | } |
| 277 | |
| 278 | ::ndk::ScopedAStatus TunerHidlService::openDescrambler( |
| 279 | int32_t /*descramblerHandle*/, shared_ptr<ITunerDescrambler>* _aidl_return) { |
| 280 | if (!hasITuner()) { |
| 281 | ALOGD("get ITuner failed"); |
| 282 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 283 | static_cast<int32_t>(Result::UNAVAILABLE)); |
| 284 | } |
| 285 | |
| 286 | HidlResult status; |
| 287 | sp<HidlIDescrambler> descrambler; |
| 288 | //int id = TunerHelper::getResourceIdFromHandle(descramblerHandle, DESCRAMBLER); |
| 289 | mTuner->openDescrambler([&](HidlResult r, const sp<HidlIDescrambler>& descramblerSp) { |
| 290 | status = r; |
| 291 | descrambler = descramblerSp; |
| 292 | }); |
| 293 | if (status != HidlResult::SUCCESS) { |
| 294 | return ::ndk::ScopedAStatus::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 295 | } |
| 296 | |
| 297 | *_aidl_return = ::ndk::SharedRefBase::make<TunerHidlDescrambler>(descrambler); |
| 298 | return ::ndk::ScopedAStatus::ok(); |
| 299 | } |
| 300 | |
| 301 | ::ndk::ScopedAStatus TunerHidlService::getTunerHalVersion(int* _aidl_return) { |
| 302 | hasITuner(); |
| 303 | *_aidl_return = mTunerVersion; |
| 304 | return ::ndk::ScopedAStatus::ok(); |
| 305 | } |
| 306 | |
| 307 | void TunerHidlService::updateTunerResources() { |
| 308 | if (!hasITuner()) { |
| 309 | ALOGE("Failed to updateTunerResources"); |
| 310 | return; |
| 311 | } |
| 312 | |
| 313 | TunerHelper::updateTunerResources(getTRMFrontendInfos(), getTRMLnbHandles()); |
| 314 | } |
| 315 | |
| 316 | vector<TunerFrontendInfo> TunerHidlService::getTRMFrontendInfos() { |
| 317 | vector<TunerFrontendInfo> infos; |
| 318 | hidl_vec<HidlFrontendId> ids; |
| 319 | HidlResult res = getHidlFrontendIds(ids); |
| 320 | if (res != HidlResult::SUCCESS) { |
| 321 | return infos; |
| 322 | } |
| 323 | |
| 324 | for (int i = 0; i < ids.size(); i++) { |
| 325 | HidlFrontendInfo frontendInfo; |
| 326 | HidlResult res = getHidlFrontendInfo(static_cast<int32_t>(ids[i]), frontendInfo); |
| 327 | if (res != HidlResult::SUCCESS) { |
| 328 | continue; |
| 329 | } |
| 330 | TunerFrontendInfo tunerFrontendInfo{ |
| 331 | .handle = TunerHelper::getResourceHandleFromId(static_cast<int32_t>(ids[i]), |
| 332 | FRONTEND), |
| 333 | .type = static_cast<int32_t>(frontendInfo.type), |
| 334 | .exclusiveGroupId = static_cast<int32_t>(frontendInfo.exclusiveGroupId), |
| 335 | }; |
| 336 | infos.push_back(tunerFrontendInfo); |
| 337 | } |
| 338 | |
| 339 | return infos; |
| 340 | } |
| 341 | |
| 342 | vector<int32_t> TunerHidlService::getTRMLnbHandles() { |
| 343 | vector<int32_t> lnbHandles; |
| 344 | if (mTuner != nullptr) { |
| 345 | HidlResult res; |
| 346 | vector<HidlLnbId> lnbIds; |
| 347 | mTuner->getLnbIds([&](HidlResult r, const hidl_vec<HidlLnbId>& ids) { |
| 348 | lnbIds = ids; |
| 349 | res = r; |
| 350 | }); |
| 351 | if (res == HidlResult::SUCCESS && lnbIds.size() > 0) { |
| 352 | for (int i = 0; i < lnbIds.size(); i++) { |
| 353 | lnbHandles.push_back( |
| 354 | TunerHelper::getResourceHandleFromId(static_cast<int32_t>(lnbIds[i]), LNB)); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | return lnbHandles; |
| 360 | } |
| 361 | |
| 362 | HidlResult TunerHidlService::getHidlFrontendIds(hidl_vec<HidlFrontendId>& ids) { |
| 363 | if (mTuner == nullptr) { |
| 364 | return HidlResult::NOT_INITIALIZED; |
| 365 | } |
| 366 | HidlResult res; |
| 367 | mTuner->getFrontendIds([&](HidlResult r, const hidl_vec<HidlFrontendId>& frontendIds) { |
| 368 | ids = frontendIds; |
| 369 | res = r; |
| 370 | }); |
| 371 | return res; |
| 372 | } |
| 373 | |
| 374 | HidlResult TunerHidlService::getHidlFrontendInfo(const int id, HidlFrontendInfo& info) { |
| 375 | if (mTuner == nullptr) { |
| 376 | return HidlResult::NOT_INITIALIZED; |
| 377 | } |
| 378 | HidlResult res; |
| 379 | mTuner->getFrontendInfo(id, [&](HidlResult r, const HidlFrontendInfo& feInfo) { |
| 380 | info = feInfo; |
| 381 | res = r; |
| 382 | }); |
| 383 | return res; |
| 384 | } |
| 385 | |
| 386 | DemuxCapabilities TunerHidlService::getAidlDemuxCaps(const HidlDemuxCapabilities& caps) { |
| 387 | DemuxCapabilities aidlCaps{ |
| 388 | .numDemux = static_cast<int32_t>(caps.numDemux), |
| 389 | .numRecord = static_cast<int32_t>(caps.numRecord), |
| 390 | .numPlayback = static_cast<int32_t>(caps.numPlayback), |
| 391 | .numTsFilter = static_cast<int32_t>(caps.numTsFilter), |
| 392 | .numSectionFilter = static_cast<int32_t>(caps.numSectionFilter), |
| 393 | .numAudioFilter = static_cast<int32_t>(caps.numAudioFilter), |
| 394 | .numVideoFilter = static_cast<int32_t>(caps.numVideoFilter), |
| 395 | .numPesFilter = static_cast<int32_t>(caps.numPesFilter), |
| 396 | .numPcrFilter = static_cast<int32_t>(caps.numPcrFilter), |
| 397 | .numBytesInSectionFilter = static_cast<int64_t>(caps.numBytesInSectionFilter), |
| 398 | .filterCaps = static_cast<int32_t>(caps.filterCaps), |
| 399 | .bTimeFilter = caps.bTimeFilter, |
| 400 | }; |
| 401 | aidlCaps.linkCaps.resize(caps.linkCaps.size()); |
| 402 | copy(caps.linkCaps.begin(), caps.linkCaps.end(), aidlCaps.linkCaps.begin()); |
| 403 | return aidlCaps; |
| 404 | } |
| 405 | |
| 406 | FrontendInfo TunerHidlService::getAidlFrontendInfo( |
| 407 | const HidlFrontendInfo& halInfo, const HidlFrontendDtmbCapabilities& halDtmbCaps) { |
| 408 | FrontendInfo info{ |
| 409 | .type = static_cast<FrontendType>(halInfo.type), |
| 410 | .minFrequency = static_cast<int64_t>(halInfo.minFrequency), |
| 411 | .maxFrequency = static_cast<int64_t>(halInfo.maxFrequency), |
| 412 | .minSymbolRate = static_cast<int32_t>(halInfo.minSymbolRate), |
| 413 | .maxSymbolRate = static_cast<int32_t>(halInfo.maxSymbolRate), |
| 414 | .acquireRange = static_cast<int64_t>(halInfo.acquireRange), |
| 415 | .exclusiveGroupId = static_cast<int32_t>(halInfo.exclusiveGroupId), |
| 416 | }; |
| 417 | for (int i = 0; i < halInfo.statusCaps.size(); i++) { |
| 418 | info.statusCaps.push_back(static_cast<FrontendStatusType>(halInfo.statusCaps[i])); |
| 419 | } |
| 420 | |
| 421 | FrontendCapabilities caps; |
| 422 | switch (halInfo.type) { |
| 423 | case ::android::hardware::tv::tuner::V1_0::FrontendType::ANALOG: { |
| 424 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::analogCaps == |
| 425 | halInfo.frontendCaps.getDiscriminator()) { |
| 426 | FrontendAnalogCapabilities analogCaps{ |
| 427 | .typeCap = static_cast<int32_t>(halInfo.frontendCaps.analogCaps().typeCap), |
| 428 | .sifStandardCap = |
| 429 | static_cast<int32_t>(halInfo.frontendCaps.analogCaps().sifStandardCap), |
| 430 | }; |
| 431 | caps.set<FrontendCapabilities::analogCaps>(analogCaps); |
| 432 | } |
| 433 | break; |
| 434 | } |
| 435 | case ::android::hardware::tv::tuner::V1_0::FrontendType::ATSC: { |
| 436 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::atscCaps == |
| 437 | halInfo.frontendCaps.getDiscriminator()) { |
| 438 | FrontendAtscCapabilities atscCaps{ |
| 439 | .modulationCap = |
| 440 | static_cast<int32_t>(halInfo.frontendCaps.atscCaps().modulationCap), |
| 441 | }; |
| 442 | caps.set<FrontendCapabilities::atscCaps>(atscCaps); |
| 443 | } |
| 444 | break; |
| 445 | } |
| 446 | case ::android::hardware::tv::tuner::V1_0::FrontendType::ATSC3: { |
| 447 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::atsc3Caps == |
| 448 | halInfo.frontendCaps.getDiscriminator()) { |
| 449 | FrontendAtsc3Capabilities atsc3Caps{ |
| 450 | .bandwidthCap = |
| 451 | static_cast<int32_t>(halInfo.frontendCaps.atsc3Caps().bandwidthCap), |
| 452 | .modulationCap = |
| 453 | static_cast<int32_t>(halInfo.frontendCaps.atsc3Caps().modulationCap), |
| 454 | .timeInterleaveModeCap = static_cast<int32_t>( |
| 455 | halInfo.frontendCaps.atsc3Caps().timeInterleaveModeCap), |
| 456 | .codeRateCap = |
| 457 | static_cast<int32_t>(halInfo.frontendCaps.atsc3Caps().codeRateCap), |
| 458 | .demodOutputFormatCap = static_cast<int8_t>( |
| 459 | halInfo.frontendCaps.atsc3Caps().demodOutputFormatCap), |
| 460 | .fecCap = static_cast<int32_t>(halInfo.frontendCaps.atsc3Caps().fecCap), |
| 461 | }; |
| 462 | caps.set<FrontendCapabilities::atsc3Caps>(atsc3Caps); |
| 463 | } |
| 464 | break; |
| 465 | } |
| 466 | case ::android::hardware::tv::tuner::V1_0::FrontendType::DVBC: { |
| 467 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::dvbcCaps == |
| 468 | halInfo.frontendCaps.getDiscriminator()) { |
| 469 | FrontendDvbcCapabilities dvbcCaps{ |
| 470 | .modulationCap = |
| 471 | static_cast<int32_t>(halInfo.frontendCaps.dvbcCaps().modulationCap), |
| 472 | .fecCap = static_cast<int64_t>(halInfo.frontendCaps.dvbcCaps().fecCap), |
| 473 | .annexCap = static_cast<int8_t>(halInfo.frontendCaps.dvbcCaps().annexCap), |
| 474 | }; |
| 475 | caps.set<FrontendCapabilities::dvbcCaps>(dvbcCaps); |
| 476 | } |
| 477 | break; |
| 478 | } |
| 479 | case ::android::hardware::tv::tuner::V1_0::FrontendType::DVBS: { |
| 480 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::dvbsCaps == |
| 481 | halInfo.frontendCaps.getDiscriminator()) { |
| 482 | FrontendDvbsCapabilities dvbsCaps{ |
| 483 | .modulationCap = |
| 484 | static_cast<int32_t>(halInfo.frontendCaps.dvbsCaps().modulationCap), |
| 485 | .innerfecCap = |
| 486 | static_cast<int64_t>(halInfo.frontendCaps.dvbsCaps().innerfecCap), |
| 487 | .standard = static_cast<int8_t>(halInfo.frontendCaps.dvbsCaps().standard), |
| 488 | }; |
| 489 | caps.set<FrontendCapabilities::dvbsCaps>(dvbsCaps); |
| 490 | } |
| 491 | break; |
| 492 | } |
| 493 | case ::android::hardware::tv::tuner::V1_0::FrontendType::DVBT: { |
| 494 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::dvbtCaps == |
| 495 | halInfo.frontendCaps.getDiscriminator()) { |
| 496 | FrontendDvbtCapabilities dvbtCaps{ |
| 497 | .transmissionModeCap = static_cast<int32_t>( |
| 498 | halInfo.frontendCaps.dvbtCaps().transmissionModeCap), |
| 499 | .bandwidthCap = |
| 500 | static_cast<int32_t>(halInfo.frontendCaps.dvbtCaps().bandwidthCap), |
| 501 | .constellationCap = |
| 502 | static_cast<int32_t>(halInfo.frontendCaps.dvbtCaps().constellationCap), |
| 503 | .coderateCap = |
| 504 | static_cast<int32_t>(halInfo.frontendCaps.dvbtCaps().coderateCap), |
| 505 | .hierarchyCap = |
| 506 | static_cast<int32_t>(halInfo.frontendCaps.dvbtCaps().hierarchyCap), |
| 507 | .guardIntervalCap = |
| 508 | static_cast<int32_t>(halInfo.frontendCaps.dvbtCaps().guardIntervalCap), |
| 509 | .isT2Supported = halInfo.frontendCaps.dvbtCaps().isT2Supported, |
| 510 | .isMisoSupported = halInfo.frontendCaps.dvbtCaps().isMisoSupported, |
| 511 | }; |
| 512 | caps.set<FrontendCapabilities::dvbtCaps>(dvbtCaps); |
| 513 | } |
| 514 | break; |
| 515 | } |
| 516 | case ::android::hardware::tv::tuner::V1_0::FrontendType::ISDBS: { |
| 517 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::isdbsCaps == |
| 518 | halInfo.frontendCaps.getDiscriminator()) { |
| 519 | FrontendIsdbsCapabilities isdbsCaps{ |
| 520 | .modulationCap = |
| 521 | static_cast<int32_t>(halInfo.frontendCaps.isdbsCaps().modulationCap), |
| 522 | .coderateCap = |
| 523 | static_cast<int32_t>(halInfo.frontendCaps.isdbsCaps().coderateCap), |
| 524 | }; |
| 525 | caps.set<FrontendCapabilities::isdbsCaps>(isdbsCaps); |
| 526 | } |
| 527 | break; |
| 528 | } |
| 529 | case ::android::hardware::tv::tuner::V1_0::FrontendType::ISDBS3: { |
| 530 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::isdbs3Caps == |
| 531 | halInfo.frontendCaps.getDiscriminator()) { |
| 532 | FrontendIsdbs3Capabilities isdbs3Caps{ |
| 533 | .modulationCap = |
| 534 | static_cast<int32_t>(halInfo.frontendCaps.isdbs3Caps().modulationCap), |
| 535 | .coderateCap = |
| 536 | static_cast<int32_t>(halInfo.frontendCaps.isdbs3Caps().coderateCap), |
| 537 | }; |
| 538 | caps.set<FrontendCapabilities::isdbs3Caps>(isdbs3Caps); |
| 539 | } |
| 540 | break; |
| 541 | } |
| 542 | case ::android::hardware::tv::tuner::V1_0::FrontendType::ISDBT: { |
| 543 | if (HidlFrontendInfo::FrontendCapabilities::hidl_discriminator::isdbtCaps == |
| 544 | halInfo.frontendCaps.getDiscriminator()) { |
| 545 | FrontendIsdbtCapabilities isdbtCaps{ |
| 546 | .modeCap = static_cast<int32_t>(halInfo.frontendCaps.isdbtCaps().modeCap), |
| 547 | .bandwidthCap = |
| 548 | static_cast<int32_t>(halInfo.frontendCaps.isdbtCaps().bandwidthCap), |
| 549 | .modulationCap = |
| 550 | static_cast<int32_t>(halInfo.frontendCaps.isdbtCaps().modulationCap), |
| 551 | .coderateCap = |
| 552 | static_cast<int32_t>(halInfo.frontendCaps.isdbtCaps().coderateCap), |
| 553 | .guardIntervalCap = |
| 554 | static_cast<int32_t>(halInfo.frontendCaps.isdbtCaps().guardIntervalCap), |
| 555 | }; |
| 556 | caps.set<FrontendCapabilities::isdbtCaps>(isdbtCaps); |
| 557 | } |
| 558 | break; |
| 559 | } |
| 560 | default: { |
| 561 | if (static_cast<HidlFrontendType>(info.type) == HidlFrontendType::DTMB) { |
| 562 | FrontendDtmbCapabilities dtmbCaps{ |
| 563 | .transmissionModeCap = static_cast<int32_t>(halDtmbCaps.transmissionModeCap), |
| 564 | .bandwidthCap = static_cast<int32_t>(halDtmbCaps.bandwidthCap), |
| 565 | .modulationCap = static_cast<int32_t>(halDtmbCaps.modulationCap), |
| 566 | .codeRateCap = static_cast<int32_t>(halDtmbCaps.codeRateCap), |
| 567 | .guardIntervalCap = static_cast<int32_t>(halDtmbCaps.guardIntervalCap), |
| 568 | .interleaveModeCap = static_cast<int32_t>(halDtmbCaps.interleaveModeCap), |
| 569 | }; |
| 570 | caps.set<FrontendCapabilities::dtmbCaps>(dtmbCaps); |
| 571 | } |
| 572 | break; |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | info.frontendCaps = caps; |
| 577 | return info; |
| 578 | } |
| 579 | |
| 580 | } // namespace tuner |
| 581 | } // namespace tv |
| 582 | } // namespace media |
| 583 | } // namespace android |
| 584 | } // namespace aidl |