Skip to content

Commit

Permalink
Bug 1036873 - Add support for standard V4L2 FM deemphasis control, r=…
Browse files Browse the repository at this point in the history
…dhylands
  • Loading branch information
michaelwu committed Jul 10, 2014
1 parent fdc7913 commit c66cc7a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions hal/gonk/GonkFMRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@
#include <sys/stat.h>
#include <sys/types.h>


/* 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 {

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit c66cc7a

Please sign in to comment.