Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19ed17bf authored by Amy Zhang's avatar Amy Zhang
Browse files

Extend Scan Message and Message Type in Tuner HAL 1.1

A new API would be added in IFrontendCallback 1.1:
onScanMessageExt to receive the extended scan message

Test: atest VtsHalTvTunerV1_1TargetTest
Bug: 158818695
Change-Id: If12535dada78ee2d2c7282ff17f9ab5f4983c750
parent 422bb11c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ hidl_interface {
        "IFilter.hal",
        "IFrontend.hal",
        "IFilterCallback.hal",
        "IFrontendCallback.hal",
        "ITuner.hal",
        "types.hal",
    ],
+32 −0
Original line number Diff line number Diff line
/*
 * 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);
};
+12 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#define LOG_TAG "android.hardware.tv.tuner@1.1-Frontend"

#include "Frontend.h"
#include <android/hardware/tv/tuner/1.0/IFrontendCallback.h>
#include <android/hardware/tv/tuner/1.1/IFrontendCallback.h>
#include <utils/Log.h>

namespace android {
@@ -118,6 +118,17 @@ Return<Result> Frontend::scan(const FrontendSettings& settings, FrontendScanType
    mCallback->onScanMessage(FrontendScanMessageType::LOCKED, msg);
    mIsLocked = true;

    sp<V1_1::IFrontendCallback> 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;
}

+7 −0
Original line number Diff line number Diff line
@@ -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<uint32_t> tsDataRate;
};

enum FrontendScanMessageTypeExt1_1 : uint32_t {
    MODULATION = @1.0::FrontendScanMessageType:ATSC3_PLP_INFO + 1,
};

typedef FrontendModulation FrontendScanMessageExt1_1;
+45 −0
Original line number Diff line number Diff line
@@ -47,6 +47,51 @@ Return<void> FrontendCallback::onScanMessage(FrontendScanMessageType type,
    return Void();
}

Return<void> 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<IFrontend>& frontend, FrontendSettings settings,
                                      FrontendSettingsExt1_1 settingsExt1_1) {
    sp<android::hardware::tv::tuner::V1_1::IFrontend> frontend_1_1;
Loading