diff --git a/hal/Hal.cpp b/hal/Hal.cpp index 790af80847d9..f09d5f622de7 100644 --- a/hal/Hal.cpp +++ b/hal/Hal.cpp @@ -1004,15 +1004,12 @@ ProcessPriorityToString(ProcessPriority aPriority, } static StaticAutoPtr > sFMRadioObservers; -static StaticAutoPtr > sFMRadioRDSObservers; static void InitializeFMRadioObserver() { if (!sFMRadioObservers) { sFMRadioObservers = new ObserverList; - sFMRadioRDSObservers = new ObserverList; - ClearOnShutdown(&sFMRadioRDSObservers); ClearOnShutdown(&sFMRadioObservers); } } @@ -1037,27 +1034,6 @@ NotifyFMRadioStatus(const FMRadioOperationInformation& aFMRadioState) { sFMRadioObservers->Broadcast(aFMRadioState); } -void -RegisterFMRadioRDSObserver(FMRadioRDSObserver* aFMRadioRDSObserver) { - AssertMainThread(); - InitializeFMRadioObserver(); - sFMRadioRDSObservers->AddObserver(aFMRadioRDSObserver); -} - -void -UnregisterFMRadioRDSObserver(FMRadioRDSObserver* aFMRadioRDSObserver) { - AssertMainThread(); - InitializeFMRadioObserver(); - sFMRadioRDSObservers->RemoveObserver(aFMRadioRDSObserver); -} - - -void -NotifyFMRadioRDSGroup(const FMRadioRDSGroup& aRDSGroup) { - InitializeFMRadioObserver(); - sFMRadioRDSObservers->Broadcast(aRDSGroup); -} - void EnableFMRadio(const FMRadioSettings& aInfo) { AssertMainThread(); @@ -1112,18 +1088,6 @@ CancelFMRadioSeek() { PROXY_IF_SANDBOXED(CancelFMRadioSeek()); } -void -EnableRDS(uint32_t aMask) { - AssertMainThread(); - PROXY_IF_SANDBOXED(EnableRDS(aMask)); -} - -void -DisableRDS() { - AssertMainThread(); - PROXY_IF_SANDBOXED(DisableRDS()); -} - FMRadioSettings GetFMBandSettings(FMRadioCountry aCountry) { FMRadioSettings settings; diff --git a/hal/Hal.h b/hal/Hal.h index 523bd32ee01f..b2aeec320198 100644 --- a/hal/Hal.h +++ b/hal/Hal.h @@ -503,28 +503,12 @@ void RegisterFMRadioObserver(hal::FMRadioObserver* aRadioObserver); */ void UnregisterFMRadioObserver(hal::FMRadioObserver* aRadioObserver); -/** - * Register an observer for the FM radio. - */ -void RegisterFMRadioRDSObserver(hal::FMRadioRDSObserver* aRDSObserver); - -/** - * Unregister the observer for the FM radio. - */ -void UnregisterFMRadioRDSObserver(hal::FMRadioRDSObserver* aRDSObserver); - /** * Notify observers that a call to EnableFMRadio, DisableFMRadio, or FMRadioSeek * has completed, and indicate what the call returned. */ void NotifyFMRadioStatus(const hal::FMRadioOperationInformation& aRadioState); -/** - * Notify observers of new RDS data - * This can be called on any thread. - */ -void NotifyFMRadioRDSGroup(const hal::FMRadioRDSGroup& aRDSGroup); - /** * Enable the FM radio and configure it according to the settings in aInfo. */ @@ -581,16 +565,6 @@ void CancelFMRadioSeek(); */ hal::FMRadioSettings GetFMBandSettings(hal::FMRadioCountry aCountry); -/** - * Enable RDS data reception - */ -void EnableRDS(uint32_t aMask); - -/** - * Disable RDS data reception - */ -void DisableRDS(); - /** * Start a watchdog to compulsively shutdown the system if it hangs. * @param aMode Specify how to shutdown the system. diff --git a/hal/HalTypes.h b/hal/HalTypes.h index a33d1a2cbac1..12cfcad516c4 100644 --- a/hal/HalTypes.h +++ b/hal/HalTypes.h @@ -225,9 +225,7 @@ enum FMRadioCountry { NUM_FM_RADIO_COUNTRY }; -class FMRadioRDSGroup; typedef Observer FMRadioObserver; -typedef Observer FMRadioRDSObserver; } // namespace hal } // namespace mozilla diff --git a/hal/fallback/FallbackFMRadio.cpp b/hal/fallback/FallbackFMRadio.cpp index ac9de9684b42..664928b9a777 100644 --- a/hal/fallback/FallbackFMRadio.cpp +++ b/hal/fallback/FallbackFMRadio.cpp @@ -57,13 +57,5 @@ void CancelFMRadioSeek() {} -void -EnableRDS(uint32_t aMask) -{} - -void -DisableRDS() -{} - } // hal_impl } // namespace mozilla diff --git a/hal/gonk/GonkFMRadio.cpp b/hal/gonk/GonkFMRadio.cpp index 7fd663ff2313..5f0406836769 100644 --- a/hal/gonk/GonkFMRadio.cpp +++ b/hal/gonk/GonkFMRadio.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -50,13 +49,10 @@ uint32_t GetFMRadioFrequency(); static int sRadioFD; static bool sRadioEnabled; -static bool sRDSEnabled; static pthread_t sRadioThread; -static pthread_t sRDSThread; static hal::FMRadioSettings sRadioSettings; static int sMsmFMVersion; static bool sMsmFMMode; -static bool sRDSSupported; static int setControl(uint32_t id, int32_t value) @@ -315,8 +311,6 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) hal::NotifyFMRadioStatus(info); return; } - - sRDSSupported = cap.capabilities & V4L2_CAP_RDS_CAPTURE; sRadioSettings = aInfo; if (sMsmFMMode) { @@ -372,9 +366,6 @@ DisableFMRadio() if (!sRadioEnabled) return; - if (sRDSEnabled) - DisableRDS(); - sRadioEnabled = false; if (sMsmFMMode) { @@ -503,186 +494,5 @@ void CancelFMRadioSeek() {} -/* Runs on the rds thread */ -static void* -readRDSDataThread(void* data) -{ - v4l2_rds_data rdsblocks[16]; - uint16_t blocks[4]; - - ScopedClose pipefd((int)data); - - ScopedClose epollfd(epoll_create(2)); - if (epollfd < 0) { - HAL_LOG(("Could not create epoll FD for RDS thread (%d)", errno)); - return nullptr; - } - - epoll_event event = { - EPOLLIN, - { 0 } - }; - - event.data.fd = pipefd; - if (epoll_ctl(epollfd, EPOLL_CTL_ADD, pipefd, &event) < 0) { - HAL_LOG(("Could not set up epoll FD for RDS thread (%d)", errno)); - return nullptr; - } - - event.data.fd = sRadioFD; - if (epoll_ctl(epollfd, EPOLL_CTL_ADD, sRadioFD, &event) < 0) { - HAL_LOG(("Could not set up epoll FD for RDS thread (%d)", errno)); - return nullptr; - } - - epoll_event events[2] = {{ 0 }}; - int event_count; - uint32_t block_bitmap = 0; - while ((event_count = epoll_wait(epollfd, events, 2, -1)) > 0 || - errno == EINTR) { - bool RDSDataAvailable = false; - for (int i = 0; i < event_count; i++) { - if (events[i].data.fd == pipefd) { - if (!sRDSEnabled) - return nullptr; - char tmp[32]; - TEMP_FAILURE_RETRY(read(pipefd, tmp, sizeof(tmp))); - } else if (events[i].data.fd == sRadioFD) { - RDSDataAvailable = true; - } - } - - if (!RDSDataAvailable) - continue; - - ssize_t len = - TEMP_FAILURE_RETRY(read(sRadioFD, rdsblocks, sizeof(rdsblocks))); - if (len < 0) { - HAL_LOG(("Unexpected error while reading RDS data %d", errno)); - return nullptr; - } - - int blockcount = len / sizeof(rdsblocks[0]); - int lastblock = -1; - for (int i = 0; i < blockcount; i++) { - if ((rdsblocks[i].block & V4L2_RDS_BLOCK_MSK) == V4L2_RDS_BLOCK_INVALID || - rdsblocks[i].block & V4L2_RDS_BLOCK_ERROR) { - block_bitmap |= 1 << V4L2_RDS_BLOCK_INVALID; - continue; - } - - int blocknum = rdsblocks[i].block & V4L2_RDS_BLOCK_MSK; - // In some cases, the full set of bits in an RDS group isn't - // needed, in which case version B RDS groups can be sent. - // Version B groups replace block C with block C' (V4L2_RDS_BLOCK_C_ALT). - // Block C' always stores the PI code, so receivers can find the PI - // code more quickly/reliably. - // However, we only process whole RDS groups, so it doesn't matter here. - if (blocknum == V4L2_RDS_BLOCK_C_ALT) - blocknum = V4L2_RDS_BLOCK_C; - if (blocknum > V4L2_RDS_BLOCK_D) { - HAL_LOG(("Unexpected RDS block number %d. This is a driver bug.", - blocknum)); - continue; - } - - if (blocknum == V4L2_RDS_BLOCK_A) - block_bitmap = 0; - - // Skip the group if we skipped a block. - // This stops us from processing blocks sent out of order. - if (block_bitmap != ((1 << blocknum) - 1)) { - block_bitmap |= 1 << V4L2_RDS_BLOCK_INVALID; - continue; - } - - block_bitmap |= 1 << blocknum; - - lastblock = blocknum; - blocks[blocknum] = (rdsblocks[i].msb << 8) | rdsblocks[i].lsb; - - // Make sure we have all 4 blocks and that they're valid - if (block_bitmap != 0x0F) - continue; - - FMRadioRDSGroup group; - group.blockA() = blocks[V4L2_RDS_BLOCK_A]; - group.blockB() = blocks[V4L2_RDS_BLOCK_B]; - group.blockC() = blocks[V4L2_RDS_BLOCK_C]; - group.blockD() = blocks[V4L2_RDS_BLOCK_D]; - NotifyFMRadioRDSGroup(group); - } - } - - return nullptr; -} - -static int sRDSPipeFD; - -void -EnableRDS(uint32_t aMask) -{ - if (!sRadioEnabled || !sRDSSupported) - return; - - if (sMsmFMMode) - setControl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK, aMask); - - if (sRDSEnabled) - return; - - int pipefd[2]; - int rc = pipe2(pipefd, O_NONBLOCK); - if (rc < 0) { - HAL_LOG(("Could not create RDS thread signaling pipes (%d)", rc)); - return; - } - - ScopedClose writefd(pipefd[1]); - ScopedClose readfd(pipefd[0]); - - rc = setControl(V4L2_CID_RDS_RECEPTION, true); - if (rc < 0) { - HAL_LOG(("Could not enable RDS reception (%d)", rc)); - return; - } - - sRDSPipeFD = writefd; - - sRDSEnabled = true; - - rc = pthread_create(&sRDSThread, nullptr, - readRDSDataThread, (void*)pipefd[0]); - if (rc) { - HAL_LOG(("Could not start RDS reception thread (%d)", rc)); - setControl(V4L2_CID_RDS_RECEPTION, false); - sRDSEnabled = false; - return; - } - - readfd.forget(); - writefd.forget(); -} - -void -DisableRDS() -{ - if (!sRadioEnabled || !sRDSEnabled) - return; - - int rc = setControl(V4L2_CID_RDS_RECEPTION, false); - if (rc < 0) { - HAL_LOG(("Could not disable RDS reception (%d)", rc)); - } - - sRDSEnabled = false; - - write(sRDSPipeFD, "x", 1); - - pthread_join(sRDSThread, nullptr); - - close(sRDSPipeFD); -} - } // hal_impl } // namespace mozilla diff --git a/hal/sandbox/PHal.ipdl b/hal/sandbox/PHal.ipdl index f45d232ed249..a52d7e6ef779 100644 --- a/hal/sandbox/PHal.ipdl +++ b/hal/sandbox/PHal.ipdl @@ -69,13 +69,6 @@ struct FMRadioOperationInformation { uint32_t frequency; }; -struct FMRadioRDSGroup { - uint16_t blockA; - uint16_t blockB; - uint16_t blockC; - uint16_t blockD; -}; - struct FMRadioSettings { FMRadioCountry country; uint32_t upperLimit; diff --git a/hal/sandbox/SandboxHal.cpp b/hal/sandbox/SandboxHal.cpp index 1f662dacfb20..f2faba6e4e36 100644 --- a/hal/sandbox/SandboxHal.cpp +++ b/hal/sandbox/SandboxHal.cpp @@ -426,18 +426,6 @@ CancelFMRadioSeek() NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts."); } -void -EnableRDS(uint32_t aMask) -{ - NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts."); -} - -void -DisableRDS() -{ - NS_RUNTIMEABORT("FM radio cannot be called from sandboxed contexts."); -} - void FactoryReset(FactoryResetReason& aReason) {