From c66cc7a979c9c0480cb1662fd3802ea667d695bb Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Thu, 10 Jul 2014 05:48:46 -0400 Subject: [PATCH] Bug 1036873 - Add support for standard V4L2 FM deemphasis control, r=dhylands --- hal/gonk/GonkFMRadio.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hal/gonk/GonkFMRadio.cpp b/hal/gonk/GonkFMRadio.cpp index 72d8d4cca4431..c7e9f84a39764 100644 --- a/hal/gonk/GonkFMRadio.cpp +++ b/hal/gonk/GonkFMRadio.cpp @@ -27,6 +27,20 @@ #include #include + +/* Bionic might not have the newer version of the v4l2 headers that + * define these controls, so we define them here if they're not found. + */ +#ifndef V4L2_CTRL_CLASS_FM_RX +#define V4L2_CTRL_CLASS_FM_RX 0x00a10000 +#define V4L2_CID_FM_RX_CLASS_BASE (V4L2_CTRL_CLASS_FM_RX | 0x900) +#define V4L2_CID_TUNE_DEEMPHASIS (V4L2_CID_FM_RX_CLASS_BASE + 1) +#define V4L2_DEEMPHASIS_DISABLED 0 +#define V4L2_DEEMPHASIS_50_uS 1 +#define V4L2_DEEMPHASIS_75_uS 2 +#define V4L2_CID_RDS_RECEPTION (V4L2_CID_FM_RX_CLASS_BASE + 2) +#endif + namespace mozilla { namespace hal_impl { @@ -318,6 +332,26 @@ EnableFMRadio(const hal::FMRadioSettings& aInfo) HAL_LOG(("Unable to adjust band limits")); } + int emphasis; + switch (aInfo.preEmphasis()) { + case 0: + emphasis = V4L2_DEEMPHASIS_DISABLED; + break; + case 50: + emphasis = V4L2_DEEMPHASIS_50_uS; + break; + case 75: + emphasis = V4L2_DEEMPHASIS_75_uS; + break; + default: + MOZ_CRASH("Invalid preemphasis setting"); + break; + } + rc = setControl(V4L2_CID_TUNE_DEEMPHASIS, emphasis); + if (rc < 0) { + HAL_LOG(("Unable to configure deemphasis")); + } + sRadioFD = fd.forget(); sRadioEnabled = true;