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

Commit 2bcd5f61 authored by Hongguang Chen's avatar Hongguang Chen Committed by Android (Google) Code Review
Browse files

Merge "Support frontend status readiness query."

parents acd3c8d9 881190f8
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.tv.tuner;
/* @hide */
@Backing(type="int") @VintfStability
enum FrontendStatusReadiness {
  UNDEFINED = 0,
  UNAVAILABLE = 1,
  UNSTABLE = 2,
  STABLE = 3,
  UNSUPPORTED = 4,
}
+1 −0
Original line number Diff line number Diff line
@@ -47,4 +47,5 @@ interface IFrontend {
  void unlinkCiCam(in int ciCamId);
  String getHardwareInfo();
  void removeOutputPid(int pid);
  android.hardware.tv.tuner.FrontendStatusReadiness[] getFrontendStatusReadiness(in android.hardware.tv.tuner.FrontendStatusType[] statusTypes);
}
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 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;

/**
 * FrontendStatus readiness status.
 * @hide
 */
@VintfStability
@Backing(type="int")
enum FrontendStatusReadiness {
    /**
     * The FrontendStatus’ readiness status for the given FrontendStatusType is
     * undefined.
     */
    UNDEFINED,

    /**
     * The FrontendStatus for the given FrontendStatusType is currently
     * unavailable.
     */
    UNAVAILABLE,

    /**
     * The FrontendStatus for the given FrontendStatusType can be read, but it’s
     * unstable.
     */
    UNSTABLE,

    /**
     * The FrontendStatus for the given FrontendStatusType can be ready, and it’s
     * stable.
     */
    STABLE,

    /**
     * The FrontendStatus for the given FrontendStatusType is not supported.
     */
    UNSUPPORTED,
}
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.hardware.tv.tuner;
import android.hardware.tv.tuner.FrontendScanType;
import android.hardware.tv.tuner.FrontendSettings;
import android.hardware.tv.tuner.FrontendStatus;
import android.hardware.tv.tuner.FrontendStatusReadiness;
import android.hardware.tv.tuner.FrontendStatusType;
import android.hardware.tv.tuner.IFrontendCallback;

@@ -155,4 +156,14 @@ interface IFrontend {
     * @return UNAVAILABLE if the frontend doesn’t support PID filtering out.
     */
    void removeOutputPid(int pid);

    /**
     * Gets FrontendStatus’ readiness statuses for given status types.
     *
     * @param statusTypes an array of status types.
     *
     * @return an array of current readiness statuses. The ith readiness status in
     *         the array presents fronted type statusTypes[i]’s readiness status.
     */
    FrontendStatusReadiness[] getFrontendStatusReadiness(in FrontendStatusType[] statusTypes);
}
+176 −0
Original line number Diff line number Diff line
@@ -34,6 +34,140 @@ Frontend::Frontend(FrontendType type, int32_t id, std::shared_ptr<Tuner> tuner)
    mTuner = tuner;
    // Init callback to nullptr
    mCallback = nullptr;

    switch (mType) {
        case FrontendType::ISDBS: {
            mFrontendCaps.set<FrontendCapabilities::Tag::isdbsCaps>(FrontendIsdbsCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::DEMOD_LOCK,
                    FrontendStatusType::SNR,
                    FrontendStatusType::FEC,
                    FrontendStatusType::MODULATION,
                    FrontendStatusType::MODULATIONS,
                    FrontendStatusType::ROLL_OFF,
                    FrontendStatusType::STREAM_ID_LIST,
            };
            break;
        }
        case FrontendType::ATSC3: {
            mFrontendCaps.set<FrontendCapabilities::Tag::atsc3Caps>(FrontendAtsc3Capabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::BER,
                    FrontendStatusType::PER,
                    FrontendStatusType::ATSC3_PLP_INFO,
                    FrontendStatusType::MODULATIONS,
                    FrontendStatusType::BERS,
                    FrontendStatusType::INTERLEAVINGS,
                    FrontendStatusType::BANDWIDTH,
                    FrontendStatusType::ATSC3_ALL_PLP_INFO,
            };
            break;
        }
        case FrontendType::DVBC: {
            mFrontendCaps.set<FrontendCapabilities::Tag::dvbcCaps>(FrontendDvbcCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::PRE_BER,       FrontendStatusType::SIGNAL_QUALITY,
                    FrontendStatusType::MODULATION,    FrontendStatusType::SPECTRAL,
                    FrontendStatusType::MODULATIONS,   FrontendStatusType::CODERATES,
                    FrontendStatusType::INTERLEAVINGS, FrontendStatusType::BANDWIDTH,
            };
            break;
        }
        case FrontendType::DVBS: {
            mFrontendCaps.set<FrontendCapabilities::Tag::dvbsCaps>(FrontendDvbsCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::SIGNAL_STRENGTH, FrontendStatusType::SYMBOL_RATE,
                    FrontendStatusType::MODULATION,      FrontendStatusType::MODULATIONS,
                    FrontendStatusType::ROLL_OFF,        FrontendStatusType::IS_MISO,
            };
            break;
        }
        case FrontendType::DVBT: {
            mFrontendCaps.set<FrontendCapabilities::Tag::dvbtCaps>(FrontendDvbtCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::EWBS,
                    FrontendStatusType::PLP_ID,
                    FrontendStatusType::HIERARCHY,
                    FrontendStatusType::MODULATIONS,
                    FrontendStatusType::BANDWIDTH,
                    FrontendStatusType::GUARD_INTERVAL,
                    FrontendStatusType::TRANSMISSION_MODE,
                    FrontendStatusType::T2_SYSTEM_ID,
                    FrontendStatusType::DVBT_CELL_IDS,
            };
            break;
        }
        case FrontendType::ISDBT: {
            FrontendIsdbtCapabilities isdbtCaps{
                    .modeCap = (int)FrontendIsdbtMode::MODE_1 | (int)FrontendIsdbtMode::MODE_2,
                    .bandwidthCap = (int)FrontendIsdbtBandwidth::BANDWIDTH_6MHZ,
                    .modulationCap = (int)FrontendIsdbtModulation::MOD_16QAM,
                    .coderateCap = (int)FrontendIsdbtCoderate::CODERATE_4_5 |
                                   (int)FrontendIsdbtCoderate::CODERATE_6_7,
                    .guardIntervalCap = (int)FrontendIsdbtGuardInterval::INTERVAL_1_128,
                    .timeInterleaveCap = (int)FrontendIsdbtTimeInterleaveMode::AUTO |
                                         (int)FrontendIsdbtTimeInterleaveMode::INTERLEAVE_1_0,
                    .isSegmentAuto = true,
                    .isFullSegment = true,
            };
            mFrontendCaps.set<FrontendCapabilities::Tag::isdbtCaps>(isdbtCaps);
            mFrontendStatusCaps = {
                    FrontendStatusType::AGC,
                    FrontendStatusType::LNA,
                    FrontendStatusType::MODULATION,
                    FrontendStatusType::MODULATIONS,
                    FrontendStatusType::BANDWIDTH,
                    FrontendStatusType::GUARD_INTERVAL,
                    FrontendStatusType::TRANSMISSION_MODE,
                    FrontendStatusType::ISDBT_SEGMENTS,
                    FrontendStatusType::ISDBT_MODE,
                    FrontendStatusType::ISDBT_PARTIAL_RECEPTION_FLAG,
                    FrontendStatusType::INTERLEAVINGS,
            };
            break;
        }
        case FrontendType::ANALOG: {
            mFrontendCaps.set<FrontendCapabilities::Tag::analogCaps>(FrontendAnalogCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::LAYER_ERROR,
                    FrontendStatusType::MER,
                    FrontendStatusType::UEC,
                    FrontendStatusType::TS_DATA_RATES,
            };
            break;
        }
        case FrontendType::ATSC: {
            mFrontendCaps.set<FrontendCapabilities::Tag::atscCaps>(FrontendAtscCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::FREQ_OFFSET,
                    FrontendStatusType::RF_LOCK,
                    FrontendStatusType::MODULATIONS,
                    FrontendStatusType::IS_LINEAR,
            };
            break;
        }
        case FrontendType::ISDBS3: {
            mFrontendCaps.set<FrontendCapabilities::Tag::isdbs3Caps>(FrontendIsdbs3Capabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::DEMOD_LOCK,      FrontendStatusType::MODULATION,
                    FrontendStatusType::MODULATIONS,     FrontendStatusType::ROLL_OFF,
                    FrontendStatusType::IS_SHORT_FRAMES, FrontendStatusType::STREAM_ID_LIST,
            };
            break;
        }
        case FrontendType::DTMB: {
            mFrontendCaps.set<FrontendCapabilities::Tag::dtmbCaps>(FrontendDtmbCapabilities());
            mFrontendStatusCaps = {
                    FrontendStatusType::MODULATIONS,       FrontendStatusType::INTERLEAVINGS,
                    FrontendStatusType::BANDWIDTH,         FrontendStatusType::GUARD_INTERVAL,
                    FrontendStatusType::TRANSMISSION_MODE,
            };
            break;
        }
        default: {
            break;
        }
    }
}

Frontend::~Frontend() {}
@@ -763,6 +897,10 @@ binder_status_t Frontend::dump(int fd, const char** /* args */, uint32_t /* numA
    dprintf(fd, "    mType: %d\n", mType);
    dprintf(fd, "    mIsLocked: %d\n", mIsLocked);
    dprintf(fd, "    mCiCamId: %d\n", mCiCamId);
    dprintf(fd, "    mFrontendStatusCaps:");
    for (int i = 0; i < mFrontendStatusCaps.size(); i++) {
        dprintf(fd, "        %d\n", mFrontendStatusCaps[i]);
    }
    return STATUS_OK;
}

@@ -780,6 +918,29 @@ binder_status_t Frontend::dump(int fd, const char** /* args */, uint32_t /* numA
            static_cast<int32_t>(Result::UNAVAILABLE));
}

::ndk::ScopedAStatus Frontend::getFrontendStatusReadiness(
        const std::vector<FrontendStatusType>& in_statusTypes,
        std::vector<FrontendStatusReadiness>* _aidl_return) {
    ALOGV("%s", __FUNCTION__);

    _aidl_return->resize(in_statusTypes.size());
    for (int i = 0; i < in_statusTypes.size(); i++) {
        int j = 0;
        while (j < mFrontendStatusCaps.size()) {
            if (in_statusTypes[i] == mFrontendStatusCaps[j]) {
                (*_aidl_return)[i] = FrontendStatusReadiness::STABLE;
                break;
            }
            j++;
        }
        if (j >= mFrontendStatusCaps.size()) {
            (*_aidl_return)[i] = FrontendStatusReadiness::UNSUPPORTED;
        }
    }

    return ::ndk::ScopedAStatus::ok();
}

FrontendType Frontend::getFrontendType() {
    return mType;
}
@@ -797,6 +958,21 @@ bool Frontend::isLocked() {
    return mIsLocked;
}

void Frontend::getFrontendInfo(FrontendInfo* _aidl_return) {
    // assign randomly selected values for testing.
    *_aidl_return = {
            .type = mType,
            .minFrequency = 139000000,
            .maxFrequency = 1139000000,
            .minSymbolRate = 45,
            .maxSymbolRate = 1145,
            .acquireRange = 30,
            .exclusiveGroupId = 57,
            .statusCaps = mFrontendStatusCaps,
            .frontendCaps = mFrontendCaps,
    };
}

}  // namespace tuner
}  // namespace tv
}  // namespace hardware
Loading