FM: Add support to receive RT+ ,ECC events
This adds configuring RDS group processing for RT+ and ECC events,
Also includes code cleanup and changes to set proper value for RDS
group processing registers during SCREEN turn on after LOW Power
mode.
Change-Id: I1a6a5ce43a855cde1e32cc5e2d3bb03fe0af2625
diff --git a/fm_hci/fm_hci.c b/fm_hci/fm_hci.c
index 2c3e2df..fec8bc7 100644
--- a/fm_hci/fm_hci.c
+++ b/fm_hci/fm_hci.c
@@ -262,11 +262,11 @@
/* Provide command credits to allow fmHCITask to send cmds */
pthread_mutex_lock(&fmHCIControlBlock.credit_lock);
if (evt_type == FM_CMD_COMPLETE) {
- ALOGE("\n%s: Command Credit(s): '%d' received as part of CC Event for FM-CMD: 0x%x%x \n", __func__, pbuf->cmd_params[0],
+ ALOGE("\n%s: Command Credit(s): '%d' received as part of CC Event for FM-CMD: 0x%x%x \n", __func__, pbuf->cmd_params[0],
pbuf->cmd_params[2], pbuf->cmd_params[1]);
command_credits = pbuf->cmd_params[0];
} else if (evt_type == FM_CMD_STATUS) {
- ALOGE("\n%s: Command Credit(s): '%d' received as part of CS Event for FM-CMD: 0x%x%x \n", __func__, pbuf->cmd_params[1],
+ ALOGE("\n%s: Command Credit(s): '%d' received as part of CS Event for FM-CMD: 0x%x%x \n", __func__, pbuf->cmd_params[1],
pbuf->cmd_params[3], pbuf->cmd_params[2]);
command_credits = pbuf->cmd_params[1];
}
@@ -275,12 +275,12 @@
}
ret = ret - (evt_len + 3);
- ALOGE("%s: Length of available bytes @ HCI Layer: %d", __func__, ret);
+ ALOGD("%s: Length of available bytes @ HCI Layer: %d", __func__, ret);
if (ret > 0) {
- ALOGE("%s: Remaining bytes of event/data: %d", __func__, ret);
+ ALOGD("%s: Remaining bytes of event/data: %d", __func__, ret);
pbuf = (FM_EVT_HDR *)&pbuf->cmd_params[evt_len];
- ALOGE("%s: Protocol byte of next packet: 0x%2x", __func__, pbuf[0]);
+ ALOGD("%s: Protocol byte of next packet: 0x%2x", __func__, pbuf[0]);
}
}
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index a4fce5d..65f33cb 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -2146,7 +2146,10 @@
bStatus = mReceiver.registerRdsGroupProcessing(FmReceiver.FM_RX_RDS_GRP_RT_EBL|
FmReceiver.FM_RX_RDS_GRP_PS_EBL|
FmReceiver.FM_RX_RDS_GRP_AF_EBL|
- FmReceiver.FM_RX_RDS_GRP_PS_SIMPLE_EBL);
+ FmReceiver.FM_RX_RDS_GRP_PS_SIMPLE_EBL|
+ FmReceiver.FM_RX_RDS_GRP_ECC_EBL|
+ FmReceiver.FM_RX_RDS_GRP_PTYN_EBL|
+ FmReceiver.FM_RX_RDS_GRP_RT_PLUS_EBL);
Log.d(LOGTAG, "registerRdsGroupProcessing done, Status :" + bStatus);
}
bStatus = enableAutoAF(FmSharedPreferences.getAutoAFSwitch());
diff --git a/helium/radio-helium-commands.h b/helium/radio-helium-commands.h
index 85acf16..c480ea0 100644
--- a/helium/radio-helium-commands.h
+++ b/helium/radio-helium-commands.h
@@ -53,7 +53,7 @@
HCI_FM_HELIUM_PSALL,
/*v4l2 Tx controls*/
- HCI_FM_HELIUM_IOVERC,
+ HCI_FM_HELIUM_IOVERC = 0x8000000 + 24,
HCI_FM_HELIUM_INTDET,
HCI_FM_HELIUM_MPX_DCC,
HCI_FM_HELIUM_AF_JUMP,
@@ -95,5 +95,4 @@
HCI_FM_HELIUM_AUDIO_MODE,
HCI_FM_HELIUM_AUDIO_MUTE,
};
-
#endif /* __RADIO_CHEROKEE_COMMANDS_H */
diff --git a/helium/radio-helium.h b/helium/radio-helium.h
index cb85bcc..430ddbf 100644
--- a/helium/radio-helium.h
+++ b/helium/radio-helium.h
@@ -481,6 +481,8 @@
#define HCI_EV_SEARCH_COMPLETE 0x12
#define HCI_EV_SEARCH_RDS_COMPLETE 0x13
#define HCI_EV_SEARCH_LIST_COMPLETE 0x14
+#define HCI_EV_RADIO_TEXT_PLUS_ID 0x18
+#define HCI_EV_RADIO_TEXT_PLUS_TAG 0x19
#define HCI_REQ_DONE 0
#define HCI_REQ_PEND 1
diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c
index ce39b59..2a3dc80 100644
--- a/helium/radio_helium_hal.c
+++ b/helium/radio_helium_hal.c
@@ -430,78 +430,53 @@
free(ev);
}
-static void hci_ev_rt_plus(struct rds_grp_data rds_buf)
+static inline void hci_ev_rt_plus_id(char *buff)
{
- char tag_type1, tag_type2;
char *data = NULL;
- int len = 0;
+ int len = 15;
unsigned short int agt;
- agt = AGT(rds_buf.rdsBlk[1].rdsLsb);
- /*right most 3 bits of Lsb of block 2
- * and left most 3 bits of Msb of block 3
- */
- tag_type1 = (((agt & TAG1_MSB_MASK) << TAG1_MSB_OFFSET) |
- (rds_buf.rdsBlk[2].rdsMsb >> TAG1_LSB_OFFSET));
-
- /*right most 1 bit of lsb of 3rd block
- * and left most 5 bits of Msb of 4th block
- */
- tag_type2 = (((rds_buf.rdsBlk[2].rdsLsb & TAG2_MSB_MASK) << TAG2_MSB_OFFSET) |
- (rds_buf.rdsBlk[3].rdsMsb >> TAG2_LSB_OFFSET));
-
- if (tag_type1 != DUMMY_CLASS)
- len += RT_PLUS_LEN_1_TAG;
- if (tag_type2 != DUMMY_CLASS)
- len += RT_PLUS_LEN_1_TAG;
-
- if (len != 0) {
- len += 2;
- data = malloc(len);
- } else {
- ALOGE("%s:Len is zero\n", LOG_TAG);
- return ;
- }
+ ALOGD("%s:%s: start", LOG_TAG, __func__);
+ data = malloc(len);
if (data != NULL) {
- data[0] = len;
- len = 1;
- data[len++] = rt_ert_flag;
- if (tag_type1 != DUMMY_CLASS) {
- data[len++] = tag_type1;
- /*start position of tag1
- *right most 5 bits of msb of 3rd block
- *and left most bit of lsb of 3rd block
- */
- data[len++] = (((rds_buf.rdsBlk[2].rdsMsb & TAG1_POS_MSB_MASK)
- << TAG1_POS_MSB_OFFSET)|
- (rds_buf.rdsBlk[2].rdsLsb >> TAG1_POS_LSB_OFFSET));
- /*length of tag1
- *left most 6 bits of lsb of 3rd block
- */
- data[len++] = ((rds_buf.rdsBlk[2].rdsLsb >> TAG1_LEN_OFFSET) &
- TAG1_LEN_MASK) + 1;
- }
- if (tag_type2 != DUMMY_CLASS) {
- data[len++] = tag_type2;
- /*start position of tag2
- *right most 3 bit of msb of 4th block
- *and left most 3 bits of lsb of 4th block
- */
- data[len++] = (((rds_buf.rdsBlk[3].rdsMsb & TAG2_POS_MSB_MASK)
- << TAG2_POS_MSB_OFFSET) |
- (rds_buf.rdsBlk[3].rdsLsb >> TAG2_POS_LSB_OFFSET));
- /*length of tag2
- *right most 5 bits of lsb of 4th block
- */
- data[len++] = (rds_buf.rdsBlk[3].rdsLsb & TAG2_LEN_MASK) + 1;
- }
- jni_cb->rt_plus_update_cb(data);
- free(data);
+ data[0] = len;
+ data[1] = buff[RDS_PTYPE];
+ data[2] = buff[RDS_PID_LOWER];
+ data[3] = buff[RDS_PID_HIGHER];
+ data[4] = buff[3];
+
+ memcpy(&data[RDS_OFFSET], &buff[4], len-RDS_OFFSET);
+ ALOGD("%s:%s: RT+ ID grouptype=0x%x%x\n", LOG_TAG, __func__,data[4]);
+ free(data);
} else {
ALOGE("%s:memory allocation failed\n", LOG_TAG);
}
}
+static void hci_ev_rt_plus_tag(char *buff)
+{
+ char *data = NULL;
+ int len = 15;
+ unsigned short int agt;
+
+ ALOGD("%s:%s: start", LOG_TAG, __func__);
+ data = malloc(len);
+ if (data != NULL) {
+ data[0] = len;
+ ALOGE("%s:%s: data length=%d\n", LOG_TAG, __func__,data[0]);
+ data[1] = buff[RDS_PTYPE];
+ data[2] = buff[RDS_PID_LOWER];
+ data[3] = buff[RDS_PID_HIGHER];
+ data[4] = buff[3];
+ memcpy(&data[RDS_OFFSET], &buff[4], len-RDS_OFFSET);
+ // data[len] = 0x00;
+ jni_cb->rt_plus_update_cb(data);
+ free(data);
+ } else {
+ ALOGE("%s:memory allocation failed\n", LOG_TAG);
+ }
+}
+
static void hci_ev_ert()
{
char *data = NULL;
@@ -637,10 +612,13 @@
}
} else {
carrier = gtc;
- if ((carrier == rt_plus_carrier))
- hci_ev_rt_plus(temp);
- else if (carrier == ert_carrier)
+ if ((carrier == rt_plus_carrier)) {
+ // hci_ev_rt_plus(temp);
+ }
+ else if (carrier == ert_carrier) {
+ ALOGE("%s:: calling event ert", __func__);
hci_buff_ert(&temp);
+ }
}
}
@@ -697,6 +675,12 @@
case HCI_EV_SEARCH_LIST_COMPLETE:
hci_ev_srch_st_list_compl(((FM_EVT_HDR *)evt_buf)->cmd_params);
break;
+ case HCI_EV_RADIO_TEXT_PLUS_ID:
+ hci_ev_rt_plus_id(((FM_EVT_HDR *)evt_buf)->cmd_params);
+ break;
+ case HCI_EV_RADIO_TEXT_PLUS_TAG:
+ hci_ev_rt_plus_tag(((FM_EVT_HDR *)evt_buf)->cmd_params);
+ break;
default:
break;
}
@@ -790,15 +774,16 @@
ALOGE("%s:Disable RDS failed", LOG_TAG);
return retval;
}
- retval = helium_set_event_mask_req(&radio->event_mask);
+ retval = helium_set_event_mask_req(radio->event_mask);
} else {
radio->event_mask = SIG_LEVEL_INTR | RDS_SYNC_INTR | AUDIO_CTRL_INTR;
- retval = helium_set_event_mask_req(&radio->event_mask);
+ retval = helium_set_event_mask_req(radio->event_mask);
if (retval < 0) {
ALOGE("%s:Enable Async events failed", LOG_TAG);
return retval;
}
- retval = helium_rds_grp_process_req(&radio->g_rds_grp_proc_ps);
+ radio->g_rds_grp_proc_ps = 0x000000FF;
+ retval = helium_rds_grp_process_req(radio->g_rds_grp_proc_ps);
}
radio->power_mode = lp_mode;
}
@@ -955,8 +940,8 @@
break;
case HCI_FM_HELIUM_RDSGROUP_PROC:
saved_val = radio->g_rds_grp_proc_ps;
- rds_grps_proc = radio->g_rds_grp_proc_ps | val;
- radio->g_rds_grp_proc_ps = (rds_grps_proc >> RDS_CONFIG_OFFSET);
+ rds_grps_proc = radio->g_rds_grp_proc_ps | (val & 0xFF);
+ radio->g_rds_grp_proc_ps = rds_grps_proc;
ret = helium_rds_grp_process_req(radio->g_rds_grp_proc_ps);
if (ret < 0) {
radio->g_rds_grp_proc_ps = saved_val;
diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp
index 8663bfe..a410eb6 100644
--- a/jni/android_hardware_fm.cpp
+++ b/jni/android_hardware_fm.cpp
@@ -213,7 +213,8 @@
return;
}
- len = (int)(rt[0] & 0x0F);
+ len = (int)(rt[0] & 0xFF);
+ ALOGV(" rt data len=%d :",len);
len = len+5;
ALOGE(" rt data len=%d :",len);
@@ -240,7 +241,7 @@
return;
}
- numPs = (int)(ps[0] & 0x0F);
+ numPs = (int)(ps[0] & 0xFF);
len = (numPs *8)+5;
ALOGE(" ps data len=%d :",len);
@@ -267,7 +268,7 @@
ALOGE("RT_PLUS");
int len;
- len = (int)(rt_plus[0] & 0x0F);
+ len = (int)(rt_plus[0] & 0xFF);
ALOGE(" rt plus len=%d :",len);
RtPlus = mCallbackEnv->NewByteArray(len);
if (RtPlus == NULL) {
@@ -290,7 +291,7 @@
return;
}
- len = (int)(ert[0] & 0x0F);
+ len = (int)(ert[0] & 0xFF);
len = len+3;
ALOGE(" ert data len=%d :",len);
@@ -569,7 +570,7 @@
(JNIEnv * env, jobject thiz, jint fd, jint id)
{
int err;
- long val;
+ int val;
ALOGE("id(%x)\n", id);
diff --git a/qcom/fmradio/FmReceiver.java b/qcom/fmradio/FmReceiver.java
index a52a233..042956a 100644
--- a/qcom/fmradio/FmReceiver.java
+++ b/qcom/fmradio/FmReceiver.java
@@ -254,8 +254,11 @@
*/
public static final int FM_RX_RDS_GRP_RT_EBL =1;
public static final int FM_RX_RDS_GRP_PS_EBL =2;
- public static final int FM_RX_RDS_GRP_AF_EBL =4;
- public static final int FM_RX_RDS_GRP_PS_SIMPLE_EBL =16;
+ public static final int FM_RX_RDS_GRP_PS_SIMPLE_EBL =4;
+ public static final int FM_RX_RDS_GRP_AF_EBL =8;
+ public static final int FM_RX_RDS_GRP_ECC_EBL =32;
+ public static final int FM_RX_RDS_GRP_PTYN_EBL =64;
+ public static final int FM_RX_RDS_GRP_RT_PLUS_EBL =128;
private static final int V4L2_CID_PRIVATE_BASE = 0x8000000;
diff --git a/qcom/fmradio/FmRxRdsData.java b/qcom/fmradio/FmRxRdsData.java
index dac4194..a504007 100644
--- a/qcom/fmradio/FmRxRdsData.java
+++ b/qcom/fmradio/FmRxRdsData.java
@@ -141,25 +141,16 @@
int re=0;
- byte rds_group_mask = (byte)FmReceiverJNI.getControlNative(mFd, V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC);
+ int rds_group_mask = FmReceiverJNI.getControlNative(mFd, V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC);
byte rdsFilt = 0;
int psAllVal=rdsMask & RDS_PS_ALL;
Log.d(LOGTAG, "In rdsOptions: rdsMask: " + rdsMask);
-
- rds_group_mask &= 0xC7;
-
-
- rds_group_mask |= ((rdsMask & 0x07) << 3);
-
+ rds_group_mask = ((rdsMask & 0x000000FF));
re = FmReceiverJNI.setControlNative(mFd, V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_PROC, rds_group_mask);
-
- re = FmReceiverJNI.setControlNative(mFd, V4L2_CID_PRIVATE_TAVARUA_PSALL, psAllVal >> 4 );
-
return re;
-
}
/* Enable auto seek to alternate frequency */