diff --git a/tv/tuner/1.1/Android.bp b/tv/tuner/1.1/Android.bp index 6cf47f57b6..daa3683fd7 100644 --- a/tv/tuner/1.1/Android.bp +++ b/tv/tuner/1.1/Android.bp @@ -7,6 +7,7 @@ hidl_interface { "IFilter.hal", "IFrontend.hal", "IFilterCallback.hal", + "IFrontendCallback.hal", "ITuner.hal", "types.hal", ], diff --git a/tv/tuner/1.1/IFrontendCallback.hal b/tv/tuner/1.1/IFrontendCallback.hal new file mode 100644 index 0000000000..e148b1ef48 --- /dev/null +++ b/tv/tuner/1.1/IFrontendCallback.hal @@ -0,0 +1,32 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.tv.tuner@1.1; + +import @1.0::IFrontendCallback; +import FrontendScanMessageExt1_1; +import FrontendScanMessageTypeExt1_1; + +interface IFrontendCallback extends @1.0::IFrontendCallback { + /** + * The callback function that must be called by HAL implementation to notify + * the client of the v1_1 extended scan messages. + * + * @param type the type of v1_1 extended scan message. + * @param message the v1_1 extended scan message sent by HAL to the client. + */ + onScanMessageExt1_1(FrontendScanMessageTypeExt1_1 type, FrontendScanMessageExt1_1 messageExt); +}; diff --git a/tv/tuner/1.1/default/Frontend.cpp b/tv/tuner/1.1/default/Frontend.cpp index c5aeace1b5..971e335700 100644 --- a/tv/tuner/1.1/default/Frontend.cpp +++ b/tv/tuner/1.1/default/Frontend.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "android.hardware.tv.tuner@1.1-Frontend" #include "Frontend.h" -#include +#include #include namespace android { @@ -118,6 +118,17 @@ Return Frontend::scan(const FrontendSettings& settings, FrontendScanType mCallback->onScanMessage(FrontendScanMessageType::LOCKED, msg); mIsLocked = true; + sp frontendCallback_v1_1 = + V1_1::IFrontendCallback::castFrom(mCallback); + if (frontendCallback_v1_1 != NULL) { + V1_1::FrontendScanMessageExt1_1 msg; + msg.dvbc(FrontendDvbcModulation::MOD_16QAM); + frontendCallback_v1_1->onScanMessageExt1_1(V1_1::FrontendScanMessageTypeExt1_1::MODULATION, + msg); + } else { + ALOGD("[Filter] Couldn't cast to V1_1 IFrontendCallback"); + } + return Result::SUCCESS; } diff --git a/tv/tuner/1.1/types.hal b/tv/tuner/1.1/types.hal index 938751351a..29b999f4d5 100644 --- a/tv/tuner/1.1/types.hal +++ b/tv/tuner/1.1/types.hal @@ -37,6 +37,7 @@ import @1.0::FrontendIsdbtBandwidth; import @1.0::FrontendIsdbtGuardInterval; import @1.0::FrontendIsdbtMode; import @1.0::FrontendIsdbtModulation; +import @1.0::FrontendScanMessageType; import @1.0::FrontendStatusType; import @1.0::FrontendType; import android.hidl.safe_union@1.0; @@ -522,3 +523,9 @@ safe_union FrontendStatusExt1_1 { */ vec tsDataRate; }; + +enum FrontendScanMessageTypeExt1_1 : uint32_t { + MODULATION = @1.0::FrontendScanMessageType:ATSC3_PLP_INFO + 1, +}; + +typedef FrontendModulation FrontendScanMessageExt1_1; diff --git a/tv/tuner/1.1/vts/functional/FrontendTests.cpp b/tv/tuner/1.1/vts/functional/FrontendTests.cpp index 1700e43553..3bc7114b17 100644 --- a/tv/tuner/1.1/vts/functional/FrontendTests.cpp +++ b/tv/tuner/1.1/vts/functional/FrontendTests.cpp @@ -47,6 +47,51 @@ Return FrontendCallback::onScanMessage(FrontendScanMessageType type, return Void(); } +Return FrontendCallback::onScanMessageExt1_1(FrontendScanMessageTypeExt1_1 type, + const FrontendScanMessageExt1_1& message) { + android::Mutex::Autolock autoLock(mMsgLock); + ALOGD("[vts] frontend ext1_1 scan message. Type: %d", type); + switch (type) { + case FrontendScanMessageTypeExt1_1::MODULATION: + readFrontendScanMessageExt1_1Modulation(message); + break; + default: + break; + } + return Void(); +} + +void FrontendCallback::readFrontendScanMessageExt1_1Modulation(FrontendModulation modulation) { + switch (modulation.getDiscriminator()) { + case FrontendModulation::hidl_discriminator::dvbc: + ALOGD("[vts] frontend ext1_1 scan message modulation dvbc: %d", modulation.dvbc()); + break; + case FrontendModulation::hidl_discriminator::dvbs: + ALOGD("[vts] frontend ext1_1 scan message modulation dvbs: %d", modulation.dvbs()); + break; + case FrontendModulation::hidl_discriminator::isdbs: + ALOGD("[vts] frontend ext1_1 scan message modulation isdbs: %d", modulation.isdbs()); + break; + case FrontendModulation::hidl_discriminator::isdbs3: + ALOGD("[vts] frontend ext1_1 scan message modulation isdbs3: %d", modulation.isdbs3()); + break; + case FrontendModulation::hidl_discriminator::isdbt: + ALOGD("[vts] frontend ext1_1 scan message modulation isdbt: %d", modulation.isdbt()); + break; + case FrontendModulation::hidl_discriminator::atsc: + ALOGD("[vts] frontend ext1_1 scan message modulation atsc: %d", modulation.atsc()); + break; + case FrontendModulation::hidl_discriminator::atsc3: + ALOGD("[vts] frontend ext1_1 scan message modulation atsc3: %d", modulation.atsc3()); + break; + case FrontendModulation::hidl_discriminator::dvbt: + ALOGD("[vts] frontend ext1_1 scan message modulation dvbt: %d", modulation.dvbt()); + break; + default: + break; + } +} + void FrontendCallback::tuneTestOnLock(sp& frontend, FrontendSettings settings, FrontendSettingsExt1_1 settingsExt1_1) { sp frontend_1_1; diff --git a/tv/tuner/1.1/vts/functional/FrontendTests.h b/tv/tuner/1.1/vts/functional/FrontendTests.h index 106f653303..243d9decd7 100644 --- a/tv/tuner/1.1/vts/functional/FrontendTests.h +++ b/tv/tuner/1.1/vts/functional/FrontendTests.h @@ -15,9 +15,9 @@ */ #include -#include #include #include +#include #include #include #include @@ -54,9 +54,12 @@ using android::hardware::tv::tuner::V1_0::FrontendScanMessage; using android::hardware::tv::tuner::V1_0::FrontendScanMessageType; using android::hardware::tv::tuner::V1_0::FrontendScanType; using android::hardware::tv::tuner::V1_0::IFrontend; -using android::hardware::tv::tuner::V1_0::IFrontendCallback; using android::hardware::tv::tuner::V1_0::Result; using android::hardware::tv::tuner::V1_1::FrontendDtmbCapabilities; +using android::hardware::tv::tuner::V1_1::FrontendModulation; +using android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1; +using android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1; +using android::hardware::tv::tuner::V1_1::IFrontendCallback; using android::hardware::tv::tuner::V1_1::ITuner; using ::testing::AssertionResult; @@ -71,6 +74,8 @@ class FrontendCallback : public IFrontendCallback { virtual Return onEvent(FrontendEventType frontendEventType) override; virtual Return onScanMessage(FrontendScanMessageType type, const FrontendScanMessage& message) override; + virtual Return onScanMessageExt1_1(FrontendScanMessageTypeExt1_1 type, + const FrontendScanMessageExt1_1& message) override; void tuneTestOnLock(sp& frontend, FrontendSettings settings, FrontendSettingsExt1_1 settingsExt1_1); @@ -81,6 +86,8 @@ class FrontendCallback : public IFrontendCallback { void resetBlindScanStartingFrequency(FrontendConfig& config, uint32_t resetingFreq); private: + void readFrontendScanMessageExt1_1Modulation(FrontendModulation modulation); + bool mEventReceived = false; bool mScanMessageReceived = false; bool mLockMsgReceived = false;