Loading broadcastradio/1.1/default/BroadcastRadio.cpp +21 −9 Original line number Diff line number Diff line Loading @@ -44,17 +44,29 @@ static const map<Class, ModuleConfig> 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 }), }, })}, Loading Loading @@ -114,14 +126,14 @@ Return<void> BroadcastRadio::getProperties_1_1(getProperties_1_1_cb _hidl_cb) { dst.antennaConnected = true; dst.lowerLimit = src.lowerLimit; dst.upperLimit = src.upperLimit; dst.spacings = vector<uint32_t>({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>(Deemphasis::D50 | Deemphasis::D75); dst.ext.fm.stereo = true; dst.ext.fm.rds = Rds::US; dst.ext.fm.rds = static_cast<Rds>(Rds::WORLD | Rds::US); dst.ext.fm.ta = true; dst.ext.fm.af = true; dst.ext.fm.ea = true; Loading broadcastradio/1.1/default/BroadcastRadio.h +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ struct AmFmBandConfig { V1_0::Band type; uint32_t lowerLimit; // kHz uint32_t upperLimit; // kHz uint32_t spacing; // kHz std::vector<uint32_t> spacings; // kHz }; struct ModuleConfig { Loading broadcastradio/1.1/default/Tuner.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ Return<Result> 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()); Loading broadcastradio/1.1/utils/Utils.cpp +16 −13 Original line number Diff line number Diff line Loading @@ -115,6 +115,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<uint32_t>(type); if (sel.primaryId.type == itype) return true; Loading Loading @@ -149,16 +157,11 @@ 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: if (isAm(band)) { type = ProgramType::AM; break; case Band::FM: case Band::FM_HD: } else if (isFm(band)) { type = ProgramType::FM; break; default: } else { LOG_ALWAYS_FATAL("Unsupported band: %s", toString(band).c_str()); } Loading Loading @@ -215,9 +218,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()); Loading broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h +3 −0 Original line number Diff line number Diff line Loading @@ -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); /** Loading Loading
broadcastradio/1.1/default/BroadcastRadio.cpp +21 −9 Original line number Diff line number Diff line Loading @@ -44,17 +44,29 @@ static const map<Class, ModuleConfig> 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 }), }, })}, Loading Loading @@ -114,14 +126,14 @@ Return<void> BroadcastRadio::getProperties_1_1(getProperties_1_1_cb _hidl_cb) { dst.antennaConnected = true; dst.lowerLimit = src.lowerLimit; dst.upperLimit = src.upperLimit; dst.spacings = vector<uint32_t>({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>(Deemphasis::D50 | Deemphasis::D75); dst.ext.fm.stereo = true; dst.ext.fm.rds = Rds::US; dst.ext.fm.rds = static_cast<Rds>(Rds::WORLD | Rds::US); dst.ext.fm.ta = true; dst.ext.fm.af = true; dst.ext.fm.ea = true; Loading
broadcastradio/1.1/default/BroadcastRadio.h +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ struct AmFmBandConfig { V1_0::Band type; uint32_t lowerLimit; // kHz uint32_t upperLimit; // kHz uint32_t spacing; // kHz std::vector<uint32_t> spacings; // kHz }; struct ModuleConfig { Loading
broadcastradio/1.1/default/Tuner.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ Return<Result> 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()); Loading
broadcastradio/1.1/utils/Utils.cpp +16 −13 Original line number Diff line number Diff line Loading @@ -115,6 +115,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<uint32_t>(type); if (sel.primaryId.type == itype) return true; Loading Loading @@ -149,16 +157,11 @@ 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: if (isAm(band)) { type = ProgramType::AM; break; case Band::FM: case Band::FM_HD: } else if (isFm(band)) { type = ProgramType::FM; break; default: } else { LOG_ALWAYS_FATAL("Unsupported band: %s", toString(band).c_str()); } Loading Loading @@ -215,9 +218,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()); Loading
broadcastradio/1.1/utils/include/broadcastradio-utils/Utils.h +3 −0 Original line number Diff line number Diff line Loading @@ -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); /** Loading