diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index 0b7a36624ba81415ef04a30ce306ece9b6d4086a..1986917c0f412eecf3f333a1b7431bc3c6aeb7c0 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -2123,7 +2123,7 @@ public class FMRadioService extends Service Log.d(LOGTAG, "fmOn: RdsStd :"+ config.getRdsStd()); Log.d(LOGTAG, "fmOn: LowerLimit :"+ config.getLowerLimit()); Log.d(LOGTAG, "fmOn: UpperLimit :"+ config.getUpperLimit()); - bStatus = mReceiver.enable(FmSharedPreferences.getFMConfiguration()); + bStatus = mReceiver.enable(FmSharedPreferences.getFMConfiguration(), this); if (isSpeakerEnabled()) { setAudioPath(false); } else { @@ -2281,7 +2281,7 @@ public class FMRadioService extends Service // This will disable the FM radio device if (mReceiver != null) { - bStatus = mReceiver.disable(); + bStatus = mReceiver.disable(this); mReceiver = null; } fmOperationsOff(); diff --git a/fmapp2/src/com/caf/fmradio/FMTransmitterService.java b/fmapp2/src/com/caf/fmradio/FMTransmitterService.java index 021e4687a5afd33698fd279e4924dec84e4c6c47..e3cf3d6ae82540717314552d9769c69889ae8f52 100644 --- a/fmapp2/src/com/caf/fmradio/FMTransmitterService.java +++ b/fmapp2/src/com/caf/fmradio/FMTransmitterService.java @@ -530,7 +530,7 @@ public class FMTransmitterService extends Service /* Disable Receiver */ if (mReceiver != null) { - bStatus = mReceiver.disable(); + bStatus = mReceiver.disable(this); mReceiver = null; } RText = " "; @@ -585,7 +585,7 @@ public class FMTransmitterService extends Service /* Disable Receiver */ if (mReceiver != null) { - bStatus = mReceiver.disable(); + bStatus = mReceiver.disable(this); mReceiver = null; } try { @@ -705,7 +705,7 @@ public class FMTransmitterService extends Service mFMOn = false; } if(null != mReceiver) { - mReceiver.disable(); + mReceiver.disable(this); mReceiver = null; } try { @@ -723,14 +723,14 @@ public class FMTransmitterService extends Service throw new RuntimeException("FmTx service not available!"); } if (mReceiver.getFMState() == mReceiver.FMState_Turned_Off) { - bStatus = mReceiver.enable(config); + bStatus = mReceiver.enable(config, this); } else { try { Thread.sleep(100); } catch (Exception ex) { Log.d( LOGTAG, "RunningThread InterruptedException"); } - bStatus = mReceiver.enable(config); + bStatus = mReceiver.enable(config, this); } if (!bStatus) { Log.e( LOGTAG, "Search for weak station failed"); diff --git a/helium/radio-helium-commands.h b/helium/radio-helium-commands.h index da02f52dd0b497dd10bc5fa0f184a47ffa08e8e5..c5dfba9f701acdb637661ef5d879d2c4f4733acb 100644 --- a/helium/radio-helium-commands.h +++ b/helium/radio-helium-commands.h @@ -100,6 +100,7 @@ enum helium_cmd_t { HCI_FM_HELIUM_RDS_GRP_COUNTERS_EXT, HCI_FM_HELIUM_AGC_UCCTRL = 0x8000043, /* 0x8000043 */ HCI_FM_HELIUM_AGC_GAIN_STATE, + HCI_FM_HELIUM_ENABLE_LPF, /*using private CIDs under userclass*/ HCI_FM_HELIUM_READ_DEFAULT = 0x00980928, diff --git a/helium/radio-helium.h b/helium/radio-helium.h index 44377487f16beb92c81d4f37f6af51bb89409cbc..30c3d0c442a2d241a12761a45266014a4940a007 100644 --- a/helium/radio-helium.h +++ b/helium/radio-helium.h @@ -283,6 +283,7 @@ struct radio_hci_dev { #define HCI_OCF_FM_GET_CH_DET_THRESHOLD 0x0018 #define HCI_OCF_FM_SET_BLND_TBL 0x001B #define HCI_OCF_FM_GET_BLND_TBL 0x001C +#define HCI_OCF_FM_LOW_PASS_FILTER_CTRL 0x001F /* HCI trans control commans opcode*/ #define HCI_OCF_FM_ENABLE_TRANS_REQ 0x0001 #define HCI_OCF_FM_DISABLE_TRANS_REQ 0x0002 @@ -1275,6 +1276,7 @@ int set_ch_det_thresholds_req(struct hci_fm_ch_det_threshold *ch_det_th); int hci_fm_default_data_read_req(struct hci_fm_def_data_rd_req *def_data_rd); int hci_fm_get_blend_req(); int hci_fm_set_blend_tbl_req(struct hci_fm_blend_table *blnd_tbl); +int hci_fm_enable_lpf(int enable); int hci_fm_default_data_write_req(struct hci_fm_def_data_wr_req * data_wrt); int hci_fm_get_station_dbg_param_req(); int hci_fm_get_station_cmd_param_req(); diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c index c3dc5594befe08a797e97b5220de83fd803c4c5a..e6ab1b1901e015905a1aef665c78073ab6b1f21a 100644 --- a/helium/radio_helium_hal.c +++ b/helium/radio_helium_hal.c @@ -488,6 +488,11 @@ static inline void hci_cmd_complete_event(char *buff) hci_cc_station_rsp(pbuf); break; + case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_LOW_PASS_FILTER_CTRL): + ALOGI("%s: recived LPF enable event", __func__); + hci_cc_rsp(pbuf); + break; + case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_STATION_DBG_PARAM): hci_cc_dbg_param_rsp(pbuf); break; @@ -1559,6 +1564,12 @@ static int set_fm_ctrl(int cmd, int val) radio->blend_tbl.BlendRmssiHi = val; ret = hci_fm_set_blend_tbl_req(&radio->blend_tbl); break; + case HCI_FM_HELIUM_ENABLE_LPF: + ALOGI("%s: val: %x", __func__, val); + if (!(ret = hci_fm_enable_lpf(val))) { + ALOGI("%s: command sent sucessfully", __func__, val); + } + break; default: ALOGE("%s:%s: Not a valid FM CMD!!", LOG_TAG, __func__); ret = 0; diff --git a/helium/radio_helium_hal_cmds.c b/helium/radio_helium_hal_cmds.c index 8feb41f87fc2d7274d50ab10f5862eea92d2e36a..79450235e4b3b5a896e86a1e8a52529a10e4b431 100644 --- a/helium/radio_helium_hal_cmds.c +++ b/helium/radio_helium_hal_cmds.c @@ -447,3 +447,15 @@ int hci_fm_get_station_dbg_param_req() HCI_OCF_FM_STATION_DBG_PARAM); return send_fm_cmd_pkt(opcode, 0, NULL); } + +int hci_fm_enable_lpf(int enable) +{ + ALOGI("%s: enable: %x", __func__, enable); + + uint16_t opcode = 0; + int enable_lpf = enable; + + opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, + HCI_OCF_FM_LOW_PASS_FILTER_CTRL); + return send_fm_cmd_pkt(opcode, sizeof(enable_lpf), &enable_lpf); +} diff --git a/qcom/fmradio/FmReceiver.java b/qcom/fmradio/FmReceiver.java index c61b78e46642dc58b3466ed9cc84088f0b3c1986..0ed41490fbe6b1b106710165eccb1157e465b740 100644 --- a/qcom/fmradio/FmReceiver.java +++ b/qcom/fmradio/FmReceiver.java @@ -28,10 +28,15 @@ package qcom.fmradio; +import android.content.Context; +import android.os.Bundle; +import android.telephony.TelephonyManager; +import android.telephony.PhoneStateListener; import android.util.Log; import android.os.SystemProperties; import java.util.Arrays; import java.lang.Runnable; + /** * This class contains all interfaces and types needed to * Control the FM receiver. @@ -46,6 +51,12 @@ public class FmReceiver extends FmTransceiver static final int GRP_3A = 64; private static final String TAG = "FMRadio"; + private static boolean mEnableLpfGsm = false; + private static boolean mEnableLpfCdma = false; + private static boolean mEnableLpfWcdma = false; + private static boolean mEnableLpfLte = false; + private static boolean mEnableLpfScdma = false; + /** * Search (seek/scan/searchlist) by decrementing the frequency * @@ -306,7 +317,6 @@ public class FmReceiver extends FmTransceiver private static final int SEARCH_MPXDCC = 0; private static final int SEARCH_SINR_INT = 1; - public boolean isSmdTransportLayer() { String transportLayer = SystemProperties.get("ro.qualcomm.bt.hci_transport"); if (transportLayer.equals("smd")) @@ -331,6 +341,31 @@ public class FmReceiver extends FmTransceiver return false; } + public PhoneStateListener mDataConnectionStateListener = new PhoneStateListener(){ + public void onDataConnectionStateChanged(int state, int networkType) { + Log.d (TAG, "state: " + Integer.toString(state) + " networkType: " + Integer.toString(networkType)); + if (state == TelephonyManager.DATA_CONNECTED) { + FMcontrolLowPassFilter(state, networkType, 1); + } else { + FMcontrolLowPassFilter(state, networkType, 0); + } + } + }; + + /* Register for wan state changes to support wan-fm concurrency */ + public void registerDataConnectionStateListener(Context mContext) { + Log.d (TAG, "registerDataConnectionStateListener"); + TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + tm.listen(mDataConnectionStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE); + } + + /* UnRegister */ + public void unregisterDataConnectionStateListener(Context mContext) { + Log.d (TAG, "unregisterDataConnectionStateListener: "); + TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + tm.listen(mDataConnectionStateListener, PhoneStateListener.LISTEN_NONE); + } + /** * Constructor for the receiver Object */ @@ -461,7 +496,7 @@ public class FmReceiver extends FmTransceiver * @see #disable * */ - public boolean enable (FmConfig configSettings){ + public boolean enable (FmConfig configSettings, Context app_context){ boolean status = false; /* * Check for FM State. @@ -493,6 +528,7 @@ public class FmReceiver extends FmTransceiver status = registerClient(mCallback); } mRdsData = new FmRxRdsData(sFd); + registerDataConnectionStateListener(app_context); } else { status = false; @@ -559,7 +595,7 @@ public class FmReceiver extends FmTransceiver * @see #enable * @see #registerClient */ - public boolean disable(){ + public boolean disable(Context app_context){ boolean status = false; /* * Check for FM State. If search is in progress, then cancel the search prior @@ -617,7 +653,7 @@ public class FmReceiver extends FmTransceiver setFMPowerState(subPwrLevel_FMTurning_Off); Log.v(TAG, "disable: CURRENT-STATE : FMRxOn ---> NEW-STATE : FMTurningOff"); super.disable(); - + unregisterDataConnectionStateListener(app_context); return true; } @@ -2820,4 +2856,40 @@ public class FmReceiver extends FmTransceiver } return; } + public void FMcontrolLowPassFilter(int state, int net_type, int enable) { + switch (net_type) + { + case TelephonyManager.NETWORK_TYPE_CDMA: + if ((state == TelephonyManager.DATA_CONNECTED) && + mEnableLpfCdma == true) { + Log.d (TAG, "enabling LPF for net_type: " + Integer.toString(net_type)); + mControl.enableLPF(sFd, enable); + } + break; + case TelephonyManager.NETWORK_TYPE_LTE: + if ((state == TelephonyManager.DATA_CONNECTED) && + mEnableLpfLte == true) { + Log.d (TAG, "enabling LPF for net_type: " + Integer.toString(net_type)); + mControl.enableLPF(sFd, enable); + } + break; + case TelephonyManager.NETWORK_TYPE_GSM: + if ((state == TelephonyManager.DATA_CONNECTED) && + mEnableLpfGsm == true) { + Log.d (TAG, "enabling LPF for net_type: " + Integer.toString(net_type)); + mControl.enableLPF(sFd, enable); + } + break; + case TelephonyManager.NETWORK_TYPE_TD_SCDMA: + if ((state == TelephonyManager.DATA_CONNECTED) && + mEnableLpfScdma == true) { + Log.d (TAG, "enabling LPF for net_type: " + Integer.toString(net_type)); + mControl.enableLPF(sFd, enable); + } + break; + default: + Log.d (TAG, "net_type " + Integer.toString(net_type) + " doesn't need LPF enabling"); + break; + } + } } diff --git a/qcom/fmradio/FmRxControls.java b/qcom/fmradio/FmRxControls.java index 701448f02825cb2ee27e0a10418bb2ce3cdcd11f..7b9fb7cc3be90fb4139bbd3eb24e7f2e02d9c354 100644 --- a/qcom/fmradio/FmRxControls.java +++ b/qcom/fmradio/FmRxControls.java @@ -100,6 +100,7 @@ class FmRxControls private static final int V4L2_CID_PRIVATE_AF_JUMP_RSSI_TH = V4L2_CID_PRIVATE_BASE + 0x3F; private static final int V4L2_CID_PRIVATE_BLEND_SINRHI = V4L2_CID_PRIVATE_BASE + 0x40; private static final int V4L2_CID_PRIVATE_BLEND_RMSSIHI = V4L2_CID_PRIVATE_BASE + 0x41; + private static final int ENABLE_LOW_PASS_FILTER = V4L2_CID_PRIVATE_BASE + 0x45; private static final int V4L2_CTRL_CLASS_USER = 0x980000; private static final int V4L2_CID_BASE = V4L2_CTRL_CLASS_USER | 0x900; @@ -196,6 +197,14 @@ class FmRxControls return re; } + public int enableLPF(int fd, int sBuff) + { + int re = FmReceiverJNI.setControlNative(fd, ENABLE_LOW_PASS_FILTER, sBuff); + if ( re < 0) + Log.e(TAG, "Failed to enable LPF"); + return re; + } + /* * Set Off channel threshold */