diff --git a/broadcastradio/1.1/default/BroadcastRadio.cpp b/broadcastradio/1.1/default/BroadcastRadio.cpp index ce7a10f5c9..38b4b99007 100644 --- a/broadcastradio/1.1/default/BroadcastRadio.cpp +++ b/broadcastradio/1.1/default/BroadcastRadio.cpp @@ -44,17 +44,29 @@ static const map gModuleConfigs{ {Class::AM_FM, ModuleConfig({ "Digital radio mock", { // amFmBands + AmFmBandConfig({ + Band::AM, + 153, // lowerLimit + 26100, // upperLimit + {5, 9, 10}, // spacings + }), + AmFmBandConfig({ + Band::FM, + 65800, // lowerLimit + 108000, // upperLimit + {10, 100, 200}, // spacings + }), AmFmBandConfig({ Band::AM_HD, - 540, // lowerLimit - 1610, // upperLimit - 10, // spacing + 153, // lowerLimit + 26100, // upperLimit + {5, 9, 10}, // spacings }), AmFmBandConfig({ Band::FM_HD, 87900, // lowerLimit 107900, // upperLimit - 200, // spacing + {200}, // spacings }), }, })}, @@ -114,14 +126,14 @@ Return BroadcastRadio::getProperties_1_1(getProperties_1_1_cb _hidl_cb) { dst.antennaConnected = true; dst.lowerLimit = src.lowerLimit; dst.upperLimit = src.upperLimit; - dst.spacings = vector({src.spacing}); + dst.spacings = src.spacings; - if (src.type == Band::AM) { + if (utils::isAm(src.type)) { dst.ext.am.stereo = true; - } else if (src.type == Band::FM) { - dst.ext.fm.deemphasis = Deemphasis::D75; + } else if (utils::isFm(src.type)) { + dst.ext.fm.deemphasis = static_cast(Deemphasis::D50 | Deemphasis::D75); dst.ext.fm.stereo = true; - dst.ext.fm.rds = Rds::US; + dst.ext.fm.rds = static_cast(Rds::WORLD | Rds::US); dst.ext.fm.ta = true; dst.ext.fm.af = true; dst.ext.fm.ea = true; diff --git a/broadcastradio/1.1/default/BroadcastRadio.h b/broadcastradio/1.1/default/BroadcastRadio.h index 71e3be8aec..a96a2ab933 100644 --- a/broadcastradio/1.1/default/BroadcastRadio.h +++ b/broadcastradio/1.1/default/BroadcastRadio.h @@ -31,7 +31,7 @@ struct AmFmBandConfig { V1_0::Band type; uint32_t lowerLimit; // kHz uint32_t upperLimit; // kHz - uint32_t spacing; // kHz + std::vector spacings; // kHz }; struct ModuleConfig { diff --git a/broadcastradio/1.1/default/Tuner.cpp b/broadcastradio/1.1/default/Tuner.cpp index 87964d3f75..9a34cb128c 100644 --- a/broadcastradio/1.1/default/Tuner.cpp +++ b/broadcastradio/1.1/default/Tuner.cpp @@ -83,7 +83,7 @@ Return Tuner::setConfiguration(const BandConfig& config) { mAmfmConfig.antennaConnected = true; mCurrentProgram = utils::make_selector(mAmfmConfig.type, mAmfmConfig.lowerLimit); - if (mAmfmConfig.type == Band::FM_HD || mAmfmConfig.type == Band::FM) { + if (utils::isFm(mAmfmConfig.type)) { mVirtualRadio = std::ref(getFmRadio()); } else { mVirtualRadio = std::ref(getAmRadio()); diff --git a/broadcastradio/1.1/utils/Utils.cpp b/broadcastradio/1.1/utils/Utils.cpp index 50a407c7b7..e880ca05c9 100644 --- a/broadcastradio/1.1/utils/Utils.cpp +++ b/broadcastradio/1.1/utils/Utils.cpp @@ -119,6 +119,14 @@ bool isAmFm(const ProgramType type) { } } +bool isAm(const Band band) { + return band == Band::AM || band == Band::AM_HD; +} + +bool isFm(const Band band) { + return band == Band::FM || band == Band::FM_HD; +} + bool hasId(const ProgramSelector& sel, const IdentifierType type) { auto itype = static_cast(type); if (sel.primaryId.type == itype) return true; @@ -153,17 +161,12 @@ ProgramSelector make_selector(Band band, uint32_t channel, uint32_t subChannel) // we can't use ProgramType::AM_HD or FM_HD, because we don't know HD station ID ProgramType type; - switch (band) { - case Band::AM: - case Band::AM_HD: - type = ProgramType::AM; - break; - case Band::FM: - case Band::FM_HD: - type = ProgramType::FM; - break; - default: - LOG_ALWAYS_FATAL("Unsupported band: %s", toString(band).c_str()); + if (isAm(band)) { + type = ProgramType::AM; + } else if (isFm(band)) { + type = ProgramType::FM; + } else { + LOG_ALWAYS_FATAL("Unsupported band: %s", toString(band).c_str()); } sel.programType = static_cast(type); @@ -219,9 +222,9 @@ bool operator==(const BandConfig& l, const BandConfig& r) { if (l.lowerLimit != r.lowerLimit) return false; if (l.upperLimit != r.upperLimit) return false; if (l.spacings != r.spacings) return false; - if (l.type == Band::AM || l.type == Band::AM_HD) { + if (V1_1::utils::isAm(l.type)) { return l.ext.am == r.ext.am; - } else if (l.type == Band::FM || l.type == Band::FM_HD) { + } else if (V1_1::utils::isFm(l.type)) { return l.ext.fm == r.ext.fm; } else { ALOGW("Unsupported band config type: %s", toString(l.type).c_str()); diff --git a/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h b/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h index 4d69c0a6aa..24c60ee460 100644 --- a/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h +++ b/broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h @@ -48,6 +48,9 @@ bool tunesTo(const ProgramSelector& pointer, const ProgramSelector& channel); ProgramType getType(const ProgramSelector& sel); bool isAmFm(const ProgramType type); +bool isAm(const V1_0::Band band); +bool isFm(const V1_0::Band band); + bool hasId(const ProgramSelector& sel, const IdentifierType type); /**