shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 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 "TunerService" |
| 18 | |
| 19 | #include <android/binder_manager.h> |
| 20 | #include <utils/Log.h> |
| 21 | #include "TunerService.h" |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 22 | #include "TunerFrontend.h" |
| 23 | #include "TunerLnb.h" |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 24 | #include "TunerDemux.h" |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 25 | |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 26 | using ::aidl::android::media::tv::tuner::TunerFrontendAnalogCapabilities; |
| 27 | using ::aidl::android::media::tv::tuner::TunerFrontendAtsc3Capabilities; |
| 28 | using ::aidl::android::media::tv::tuner::TunerFrontendAtscCapabilities; |
| 29 | using ::aidl::android::media::tv::tuner::TunerFrontendCableCapabilities; |
| 30 | using ::aidl::android::media::tv::tuner::TunerFrontendCapabilities; |
| 31 | using ::aidl::android::media::tv::tuner::TunerFrontendDvbsCapabilities; |
| 32 | using ::aidl::android::media::tv::tuner::TunerFrontendDvbtCapabilities; |
| 33 | using ::aidl::android::media::tv::tuner::TunerFrontendIsdbs3Capabilities; |
| 34 | using ::aidl::android::media::tv::tuner::TunerFrontendIsdbsCapabilities; |
| 35 | using ::aidl::android::media::tv::tuner::TunerFrontendIsdbtCapabilities; |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 36 | using ::android::hardware::hidl_vec; |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 37 | using ::android::hardware::tv::tuner::V1_0::DemuxFilterAvSettings; |
| 38 | using ::android::hardware::tv::tuner::V1_0::DemuxFilterMainType; |
| 39 | using ::android::hardware::tv::tuner::V1_0::DemuxFilterSettings; |
| 40 | using ::android::hardware::tv::tuner::V1_0::DemuxFilterType; |
| 41 | using ::android::hardware::tv::tuner::V1_0::DemuxTsFilterType; |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 42 | using ::android::hardware::tv::tuner::V1_0::FrontendId; |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 43 | using ::android::hardware::tv::tuner::V1_0::FrontendType; |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 44 | using ::android::hardware::tv::tuner::V1_0::IFrontend; |
| 45 | using ::android::hardware::tv::tuner::V1_0::ILnb; |
| 46 | using ::android::hardware::tv::tuner::V1_0::LnbId; |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 47 | using ::android::hardware::tv::tuner::V1_0::Result; |
| 48 | |
| 49 | namespace android { |
| 50 | |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 51 | TunerService::TunerService() {} |
| 52 | TunerService::~TunerService() {} |
| 53 | |
| 54 | void TunerService::instantiate() { |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 55 | shared_ptr<TunerService> service = |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 56 | ::ndk::SharedRefBase::make<TunerService>(); |
| 57 | AServiceManager_addService(service->asBinder().get(), getServiceName()); |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | template <typename HidlPayload, typename AidlPayload, typename AidlFlavor> |
| 61 | bool TunerService::unsafeHidlToAidlMQDescriptor( |
| 62 | const hardware::MQDescriptor<HidlPayload, FlavorTypeToValue<AidlFlavor>::value>& hidlDesc, |
| 63 | MQDescriptor<AidlPayload, AidlFlavor>* aidlDesc) { |
| 64 | // TODO: use the builtin coversion method when it's merged. |
| 65 | ALOGD("unsafeHidlToAidlMQDescriptor"); |
| 66 | static_assert(sizeof(HidlPayload) == sizeof(AidlPayload), "Payload types are incompatible"); |
| 67 | static_assert( |
| 68 | has_typedef_fixed_size<AidlPayload>::value == true || |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 69 | is_fundamental<AidlPayload>::value || |
| 70 | is_enum<AidlPayload>::value, |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 71 | "Only fundamental types, enums, and AIDL parcelables annotated with @FixedSize " |
| 72 | "and built for the NDK backend are supported as AIDL payload types."); |
| 73 | aidlDesc->fileDescriptor = ndk::ScopedFileDescriptor(dup(hidlDesc.handle()->data[0])); |
| 74 | for (const auto& grantor : hidlDesc.grantors()) { |
| 75 | if (static_cast<int32_t>(grantor.offset) < 0 || static_cast<int64_t>(grantor.extent) < 0) { |
| 76 | ALOGD("Unsafe static_cast of grantor fields. offset=%d, extend=%ld", |
| 77 | static_cast<int32_t>(grantor.offset), static_cast<long>(grantor.extent)); |
| 78 | logError( |
| 79 | "Unsafe static_cast of grantor fields. Either the hardware::MQDescriptor is " |
| 80 | "invalid, or the MessageQueue is too large to be described by AIDL."); |
| 81 | return false; |
| 82 | } |
| 83 | aidlDesc->grantors.push_back( |
| 84 | GrantorDescriptor { |
| 85 | .offset = static_cast<int32_t>(grantor.offset), |
| 86 | .extent = static_cast<int64_t>(grantor.extent) |
| 87 | }); |
| 88 | } |
| 89 | if (static_cast<int32_t>(hidlDesc.getQuantum()) < 0 || |
| 90 | static_cast<int32_t>(hidlDesc.getFlags()) < 0) { |
| 91 | ALOGD("Unsafe static_cast of quantum or flags. Quantum=%d, flags=%d", |
| 92 | static_cast<int32_t>(hidlDesc.getQuantum()), |
| 93 | static_cast<int32_t>(hidlDesc.getFlags())); |
| 94 | logError( |
| 95 | "Unsafe static_cast of quantum or flags. Either the hardware::MQDescriptor is " |
| 96 | "invalid, or the MessageQueue is too large to be described by AIDL."); |
| 97 | return false; |
| 98 | } |
| 99 | aidlDesc->quantum = static_cast<int32_t>(hidlDesc.getQuantum()); |
| 100 | aidlDesc->flags = static_cast<int32_t>(hidlDesc.getFlags()); |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | bool TunerService::getITuner() { |
| 105 | ALOGD("getITuner"); |
| 106 | if (mTuner != nullptr) { |
| 107 | return true; |
| 108 | } |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 109 | mTuner = ITuner::getService(); |
| 110 | if (mTuner == nullptr) { |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 111 | ALOGE("Failed to get ITuner service"); |
| 112 | return false; |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 113 | } |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 114 | return true; |
| 115 | } |
| 116 | |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 117 | Status TunerService::openDemux( |
| 118 | int /* demuxHandle */, std::shared_ptr<ITunerDemux>* _aidl_return) { |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 119 | ALOGD("openDemux"); |
| 120 | if (!getITuner()) { |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 121 | return Status::fromServiceSpecificError(static_cast<int32_t>(Result::NOT_INITIALIZED)); |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 122 | } |
| 123 | if (mDemux != nullptr) { |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 124 | *_aidl_return = mDemux->ref<ITunerDemux>(); |
| 125 | return Status::ok(); |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 126 | } |
| 127 | Result res; |
| 128 | uint32_t id; |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 129 | sp<IDemux> demuxSp = nullptr; |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 130 | mTuner->openDemux([&](Result r, uint32_t demuxId, const sp<IDemux>& demux) { |
| 131 | demuxSp = demux; |
| 132 | id = demuxId; |
| 133 | res = r; |
| 134 | ALOGD("open demux, id = %d", demuxId); |
| 135 | }); |
| 136 | if (res == Result::SUCCESS) { |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 137 | mDemux = ::ndk::SharedRefBase::make<TunerDemux>(demuxSp, id); |
| 138 | *_aidl_return = mDemux->ref<ITunerDemux>(); |
| 139 | return Status::ok(); |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 140 | } |
| 141 | |
shubang | ae56a2e | 2021-01-21 07:29:55 -0800 | [diff] [blame] | 142 | ALOGD("open demux failed, res = %d", res); |
| 143 | mDemux = nullptr; |
| 144 | return Status::fromServiceSpecificError(static_cast<int32_t>(res)); |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | Result TunerService::configFilter() { |
| 148 | ALOGD("configFilter"); |
| 149 | if (mFilter == NULL) { |
| 150 | ALOGD("Failed to configure filter: filter not found"); |
| 151 | return Result::NOT_INITIALIZED; |
| 152 | } |
| 153 | DemuxFilterSettings filterSettings; |
| 154 | DemuxTsFilterSettings tsFilterSettings { |
| 155 | .tpid = 256, |
| 156 | }; |
| 157 | DemuxFilterAvSettings filterAvSettings { |
| 158 | .isPassthrough = false, |
| 159 | }; |
| 160 | tsFilterSettings.filterSettings.av(filterAvSettings); |
| 161 | filterSettings.ts(tsFilterSettings); |
| 162 | Result res = mFilter->configure(filterSettings); |
| 163 | |
| 164 | if (res != Result::SUCCESS) { |
| 165 | ALOGD("config filter failed, res = %d", res); |
| 166 | return res; |
| 167 | } |
| 168 | |
| 169 | Result getQueueDescResult = Result::UNKNOWN_ERROR; |
| 170 | mFilter->getQueueDesc( |
| 171 | [&](Result r, const MQDescriptorSync<uint8_t>& desc) { |
| 172 | mFilterMQDesc = desc; |
| 173 | getQueueDescResult = r; |
| 174 | ALOGD("getFilterQueueDesc"); |
| 175 | }); |
| 176 | if (getQueueDescResult == Result::SUCCESS) { |
| 177 | unsafeHidlToAidlMQDescriptor<uint8_t, int8_t, SynchronizedReadWrite>( |
| 178 | mFilterMQDesc, &mAidlMQDesc); |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 179 | mAidlMq = new (nothrow) AidlMessageQueue(mAidlMQDesc); |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 180 | EventFlag::createEventFlag(mAidlMq->getEventFlagWord(), &mEventFlag); |
| 181 | } else { |
| 182 | ALOGD("get MQDesc failed, res = %d", getQueueDescResult); |
| 183 | } |
| 184 | return getQueueDescResult; |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 187 | Status TunerService::getFrontendIds(vector<int32_t>* ids, int32_t* /* _aidl_return */) { |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 188 | if (!getITuner()) { |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 189 | return Status::fromServiceSpecificError( |
shubang | 6d26626 | 2020-10-09 00:15:04 -0700 | [diff] [blame] | 190 | static_cast<int32_t>(Result::NOT_INITIALIZED)); |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 191 | } |
| 192 | hidl_vec<FrontendId> feIds; |
| 193 | Result res; |
| 194 | mTuner->getFrontendIds([&](Result r, const hidl_vec<FrontendId>& frontendIds) { |
| 195 | feIds = frontendIds; |
| 196 | res = r; |
| 197 | }); |
| 198 | if (res != Result::SUCCESS) { |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 199 | return Status::fromServiceSpecificError(static_cast<int32_t>(res)); |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 200 | } |
| 201 | ids->resize(feIds.size()); |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 202 | copy(feIds.begin(), feIds.end(), ids->begin()); |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 203 | |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 204 | return Status::ok(); |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 207 | Status TunerService::getFrontendInfo( |
Amy Zhang | 1d28bbb | 2021-01-13 18:11:15 -0800 | [diff] [blame] | 208 | int32_t frontendHandle, TunerFrontendInfo* _aidl_return) { |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 209 | if (mTuner == nullptr) { |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 210 | ALOGE("ITuner service is not init."); |
| 211 | return ::ndk::ScopedAStatus::fromServiceSpecificError( |
| 212 | static_cast<int32_t>(Result::UNAVAILABLE)); |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | Result res; |
| 216 | FrontendInfo info; |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 217 | int feId = getResourceIdFromHandle(frontendHandle, FRONTEND); |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 218 | mTuner->getFrontendInfo(feId, [&](Result r, const FrontendInfo& feInfo) { |
| 219 | info = feInfo; |
| 220 | res = r; |
| 221 | }); |
| 222 | if (res != Result::SUCCESS) { |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 223 | return Status::fromServiceSpecificError(static_cast<int32_t>(res)); |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Amy Zhang | 1d28bbb | 2021-01-13 18:11:15 -0800 | [diff] [blame] | 226 | TunerFrontendInfo tunerInfo = convertToAidlFrontendInfo(info); |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 227 | *_aidl_return = tunerInfo; |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 228 | return Status::ok(); |
| 229 | } |
| 230 | |
| 231 | Status TunerService::openFrontend( |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 232 | int32_t frontendHandle, shared_ptr<ITunerFrontend>* _aidl_return) { |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 233 | if (mTuner == nullptr) { |
| 234 | ALOGE("ITuner service is not init."); |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 235 | return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE)); |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 238 | Result status; |
| 239 | sp<IFrontend> frontend; |
| 240 | int id = getResourceIdFromHandle(frontendHandle, FRONTEND); |
| 241 | mTuner->openFrontendById(id, [&](Result result, const sp<IFrontend>& fe) { |
| 242 | frontend = fe; |
| 243 | status = result; |
| 244 | }); |
| 245 | if (status != Result::SUCCESS) { |
| 246 | return Status::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 247 | } |
| 248 | *_aidl_return = ::ndk::SharedRefBase::make<TunerFrontend>(frontend, id); |
| 249 | return Status::ok(); |
| 250 | } |
| 251 | |
| 252 | Status TunerService::getFmqSyncReadWrite( |
| 253 | MQDescriptor<int8_t, SynchronizedReadWrite>* mqDesc, bool* _aidl_return) { |
| 254 | ALOGD("getFmqSyncReadWrite"); |
| 255 | // TODO: put the following methods AIDL, and should be called from clients. |
Amy Zhang | a046eee | 2021-01-12 14:44:58 -0800 | [diff] [blame] | 256 | configFilter(); |
| 257 | mFilter->start(); |
| 258 | if (mqDesc == nullptr) { |
| 259 | ALOGD("getFmqSyncReadWrite null MQDescriptor."); |
| 260 | *_aidl_return = false; |
| 261 | } else { |
| 262 | ALOGD("getFmqSyncReadWrite true"); |
| 263 | *_aidl_return = true; |
| 264 | *mqDesc = move(mAidlMQDesc); |
| 265 | } |
| 266 | return ndk::ScopedAStatus::ok(); |
| 267 | } |
| 268 | |
| 269 | Status TunerService::openLnb(int lnbHandle, shared_ptr<ITunerLnb>* _aidl_return) { |
| 270 | if (mTuner == nullptr) { |
| 271 | ALOGE("ITuner service is not init."); |
| 272 | return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE)); |
| 273 | } |
| 274 | |
| 275 | Result status; |
| 276 | sp<ILnb> lnb; |
| 277 | int id = getResourceIdFromHandle(lnbHandle, LNB); |
| 278 | mTuner->openLnbById(id, [&](Result result, const sp<ILnb>& lnbSp){ |
| 279 | lnb = lnbSp; |
| 280 | status = result; |
| 281 | }); |
| 282 | if (status != Result::SUCCESS) { |
| 283 | return Status::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 284 | } |
| 285 | |
| 286 | *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, id); |
| 287 | return Status::ok(); |
| 288 | } |
| 289 | |
| 290 | Status TunerService::openLnbByName(const string& lnbName, shared_ptr<ITunerLnb>* _aidl_return) { |
| 291 | if (mTuner == nullptr) { |
| 292 | ALOGE("ITuner service is not init."); |
| 293 | return Status::fromServiceSpecificError(static_cast<int32_t>(Result::UNAVAILABLE)); |
| 294 | } |
| 295 | |
| 296 | int lnbId; |
| 297 | Result status; |
| 298 | sp<ILnb> lnb; |
| 299 | mTuner->openLnbByName(lnbName, [&](Result r, LnbId id, const sp<ILnb>& lnbSp) { |
| 300 | status = r; |
| 301 | lnb = lnbSp; |
| 302 | lnbId = (int)id; |
| 303 | }); |
| 304 | if (status != Result::SUCCESS) { |
| 305 | return Status::fromServiceSpecificError(static_cast<int32_t>(status)); |
| 306 | } |
| 307 | |
| 308 | *_aidl_return = ::ndk::SharedRefBase::make<TunerLnb>(lnb, lnbId); |
Amy Zhang | 0f04c45 | 2020-10-30 13:36:44 -0700 | [diff] [blame] | 309 | return Status::ok(); |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Amy Zhang | 1d28bbb | 2021-01-13 18:11:15 -0800 | [diff] [blame] | 312 | TunerFrontendInfo TunerService::convertToAidlFrontendInfo(FrontendInfo halInfo) { |
| 313 | TunerFrontendInfo info{ |
Amy Zhang | 70de35a | 2020-10-12 20:13:16 -0700 | [diff] [blame] | 314 | .type = (int)halInfo.type, |
| 315 | .minFrequency = (int)halInfo.minFrequency, |
| 316 | .maxFrequency = (int)halInfo.maxFrequency, |
| 317 | .minSymbolRate = (int)halInfo.minSymbolRate, |
| 318 | .maxSymbolRate = (int)halInfo.maxSymbolRate, |
| 319 | .acquireRange = (int)halInfo.acquireRange, |
| 320 | .exclusiveGroupId = (int)halInfo.exclusiveGroupId, |
| 321 | }; |
| 322 | for (int i = 0; i < halInfo.statusCaps.size(); i++) { |
| 323 | info.statusCaps.push_back((int)halInfo.statusCaps[i]); |
| 324 | } |
| 325 | |
| 326 | TunerFrontendCapabilities caps; |
| 327 | switch (halInfo.type) { |
| 328 | case FrontendType::ANALOG: { |
| 329 | TunerFrontendAnalogCapabilities analogCaps{ |
| 330 | .typeCap = (int)halInfo.frontendCaps.analogCaps().typeCap, |
| 331 | .sifStandardCap = (int)halInfo.frontendCaps.analogCaps().sifStandardCap, |
| 332 | }; |
| 333 | caps.set<TunerFrontendCapabilities::analogCaps>(analogCaps); |
| 334 | break; |
| 335 | } |
| 336 | case FrontendType::ATSC: { |
| 337 | TunerFrontendAtscCapabilities atscCaps{ |
| 338 | .modulationCap = (int)halInfo.frontendCaps.atscCaps().modulationCap, |
| 339 | }; |
| 340 | caps.set<TunerFrontendCapabilities::atscCaps>(atscCaps); |
| 341 | break; |
| 342 | } |
| 343 | case FrontendType::ATSC3: { |
| 344 | TunerFrontendAtsc3Capabilities atsc3Caps{ |
| 345 | .bandwidthCap = (int)halInfo.frontendCaps.atsc3Caps().bandwidthCap, |
| 346 | .modulationCap = (int)halInfo.frontendCaps.atsc3Caps().modulationCap, |
| 347 | .timeInterleaveModeCap = |
| 348 | (int)halInfo.frontendCaps.atsc3Caps().timeInterleaveModeCap, |
| 349 | .codeRateCap = (int)halInfo.frontendCaps.atsc3Caps().codeRateCap, |
| 350 | .demodOutputFormatCap = (int)halInfo.frontendCaps.atsc3Caps().demodOutputFormatCap, |
| 351 | .fecCap = (int)halInfo.frontendCaps.atsc3Caps().fecCap, |
| 352 | }; |
| 353 | caps.set<TunerFrontendCapabilities::atsc3Caps>(atsc3Caps); |
| 354 | break; |
| 355 | } |
| 356 | case FrontendType::DVBC: { |
| 357 | TunerFrontendCableCapabilities cableCaps{ |
| 358 | .modulationCap = (int)halInfo.frontendCaps.dvbcCaps().modulationCap, |
| 359 | .codeRateCap = (int)halInfo.frontendCaps.dvbcCaps().fecCap, |
| 360 | .annexCap = (int)halInfo.frontendCaps.dvbcCaps().annexCap, |
| 361 | }; |
| 362 | caps.set<TunerFrontendCapabilities::cableCaps>(cableCaps); |
| 363 | break; |
| 364 | } |
| 365 | case FrontendType::DVBS: { |
| 366 | TunerFrontendDvbsCapabilities dvbsCaps{ |
| 367 | .modulationCap = (int)halInfo.frontendCaps.dvbsCaps().modulationCap, |
| 368 | .codeRateCap = (long)halInfo.frontendCaps.dvbsCaps().innerfecCap, |
| 369 | .standard = (int)halInfo.frontendCaps.dvbsCaps().standard, |
| 370 | }; |
| 371 | caps.set<TunerFrontendCapabilities::dvbsCaps>(dvbsCaps); |
| 372 | break; |
| 373 | } |
| 374 | case FrontendType::DVBT: { |
| 375 | TunerFrontendDvbtCapabilities dvbtCaps{ |
| 376 | .transmissionModeCap = (int)halInfo.frontendCaps.dvbtCaps().transmissionModeCap, |
| 377 | .bandwidthCap = (int)halInfo.frontendCaps.dvbtCaps().bandwidthCap, |
| 378 | .constellationCap = (int)halInfo.frontendCaps.dvbtCaps().constellationCap, |
| 379 | .codeRateCap = (int)halInfo.frontendCaps.dvbtCaps().coderateCap, |
| 380 | .hierarchyCap = (int)halInfo.frontendCaps.dvbtCaps().hierarchyCap, |
| 381 | .guardIntervalCap = (int)halInfo.frontendCaps.dvbtCaps().guardIntervalCap, |
| 382 | .isT2Supported = (bool)halInfo.frontendCaps.dvbtCaps().isT2Supported, |
| 383 | .isMisoSupported = (bool)halInfo.frontendCaps.dvbtCaps().isMisoSupported, |
| 384 | }; |
| 385 | caps.set<TunerFrontendCapabilities::dvbtCaps>(dvbtCaps); |
| 386 | break; |
| 387 | } |
| 388 | case FrontendType::ISDBS: { |
| 389 | TunerFrontendIsdbsCapabilities isdbsCaps{ |
| 390 | .modulationCap = (int)halInfo.frontendCaps.isdbsCaps().modulationCap, |
| 391 | .codeRateCap = (int)halInfo.frontendCaps.isdbsCaps().coderateCap, |
| 392 | }; |
| 393 | caps.set<TunerFrontendCapabilities::isdbsCaps>(isdbsCaps); |
| 394 | break; |
| 395 | } |
| 396 | case FrontendType::ISDBS3: { |
| 397 | TunerFrontendIsdbs3Capabilities isdbs3Caps{ |
| 398 | .modulationCap = (int)halInfo.frontendCaps.isdbs3Caps().modulationCap, |
| 399 | .codeRateCap = (int)halInfo.frontendCaps.isdbs3Caps().coderateCap, |
| 400 | }; |
| 401 | caps.set<TunerFrontendCapabilities::isdbs3Caps>(isdbs3Caps); |
| 402 | break; |
| 403 | } |
| 404 | case FrontendType::ISDBT: { |
| 405 | TunerFrontendIsdbtCapabilities isdbtCaps{ |
| 406 | .modeCap = (int)halInfo.frontendCaps.isdbtCaps().modeCap, |
| 407 | .bandwidthCap = (int)halInfo.frontendCaps.isdbtCaps().bandwidthCap, |
| 408 | .modulationCap = (int)halInfo.frontendCaps.isdbtCaps().modulationCap, |
| 409 | .codeRateCap = (int)halInfo.frontendCaps.isdbtCaps().coderateCap, |
| 410 | .guardIntervalCap = (int)halInfo.frontendCaps.isdbtCaps().guardIntervalCap, |
| 411 | }; |
| 412 | caps.set<TunerFrontendCapabilities::isdbtCaps>(isdbtCaps); |
| 413 | break; |
| 414 | } |
| 415 | default: |
| 416 | break; |
| 417 | } |
| 418 | |
| 419 | info.caps = caps; |
| 420 | return info; |
| 421 | } |
shubang | 23aa3ac | 2020-09-07 18:56:28 -0700 | [diff] [blame] | 422 | } // namespace android |