From 84e51de2ea1b5d2e34dfa2a6801bc92ce49b0750 Mon Sep 17 00:00:00 2001 From: Satish kumar sugasi <ssugas@codeaurora.org> Date: Wed, 30 Sep 2015 18:27:43 -0700 Subject: [PATCH] FM : Changes to add new hci commands for ftm This include adding support to read RDS group counters and other diagnoistic hci commands used for FTM app. Change-Id: I56656dc9d427a32f0385f586535d3421ff4f49b0 --- helium/radio-helium.h | 20 +++++++++++++++++ helium/radio_helium_hal.c | 40 +++++++++++++++++++++++++++++++++- helium/radio_helium_hal_cmds.c | 28 ++++++++++++++++++++++++ jni/android_hardware_fm.cpp | 9 +++++++- 4 files changed, 95 insertions(+), 2 deletions(-) diff --git a/helium/radio-helium.h b/helium/radio-helium.h index 430ddbf..9952884 100644 --- a/helium/radio-helium.h +++ b/helium/radio-helium.h @@ -159,6 +159,7 @@ typedef void (*rt_plus_cb)(char *rt_plus); typedef void (*ert_cb)(char *ert); typedef void (*disable_cb)(); typedef void (*callback_thread_event)(unsigned int evt); +typedef void (*rds_grp_cntrs_cb)(char *rds_params); typedef struct { size_t size; @@ -177,6 +178,7 @@ typedef struct { rt_plus_cb rt_plus_update_cb; ert_cb ert_update_cb; disable_cb disabled_cb; + rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb; callback_thread_event thread_evt_cb; } fm_vendor_callbacks_t; @@ -387,6 +389,18 @@ struct hci_fm_search_rds_station_req { short srch_pi; } ; +struct hci_fm_rds_grp_cntrs_params { + int totalRdsSBlockErrors; + int totalRdsGroups; + int totalRdsGroup0; + int totalRdsGroup2; + int totalRdsBlockB; + int totalRdsProcessedGroup0; + int totalRdsProcessedGroup2; + int totalRdsGroupFiltered; + int totalRdsChangeFiltered; +} ; + struct hci_fm_search_station_list_req { char srch_list_mode; char srch_list_dir; @@ -623,6 +637,12 @@ struct hci_fm_conf_rsp { struct hci_fm_recv_conf_req recv_conf_rsp; } ; +struct hci_fm_rds_grp_cntrs_rsp { + char status; + struct hci_fm_rds_grp_cntrs_params recv_rds_grp_cntrs_rsp; +} ; + + struct hci_fm_get_trans_conf_rsp { char status; struct hci_fm_trans_conf_req_struct trans_conf_rsp; diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c index 2a3dc80..0c68972 100644 --- a/helium/radio_helium_hal.c +++ b/helium/radio_helium_hal.c @@ -119,6 +119,23 @@ static void hci_cc_rsp(char *ev_buff) radio_hci_req_complete(status); } +static void hci_cc_rds_grp_cntrs_rsp(char *ev_buff) +{ + char status; + if (ev_buff == NULL) { + ALOGE("%s:%s, buffer is null\n", LOG_TAG, __func__); + return; + } + status = ev_buff[0]; + ALOGE("%s:%s, status =%d\n", LOG_TAG, __func__,status); + if(status < 0) + { + ALOGE("%s:%s, read rds_grp_cntrs failed status=%d\n", LOG_TAG, __func__,status); + } + jni_cb->rds_grp_cntrs_rsp_cb(&ev_buff[1]); +} + + static inline void hci_cmd_complete_event(char *buff) { uint16_t opcode; @@ -169,6 +186,9 @@ static inline void hci_cmd_complete_event(char *buff) case hci_common_cmd_op_pack(HCI_OCF_FM_SET_SPUR_TABLE): hci_cc_rsp(pbuf); break; + case hci_status_param_op_pack(HCI_OCF_FM_READ_GRP_COUNTERS): + hci_cc_rds_grp_cntrs_rsp(pbuf); + break; /* case hci_common_cmd_op_pack(HCI_OCF_FM_GET_SPUR_TABLE): hci_cc_get_spur_tbl(buff); break; @@ -463,7 +483,7 @@ static void hci_ev_rt_plus_tag(char *buff) data = malloc(len); if (data != NULL) { data[0] = len; - ALOGE("%s:%s: data length=%d\n", LOG_TAG, __func__,data[0]); + ALOGI("%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]; @@ -948,6 +968,24 @@ static int set_fm_ctrl(int cmd, int val) goto END; } break; + + case HCI_FM_HELIUM_RDS_GRP_COUNTERS: + ALOGD("%s: rds_grp counter read value=%d ", LOG_TAG,val); + ret = hci_fm_get_rds_grpcounters_req(val); + if (ret < 0) { + radio->g_rds_grp_proc_ps = saved_val; + goto END; + } + break; + + case HCI_FM_HELIUM_SET_NOTCH_FILTER: + ALOGD("%s: set notch filter notch=%d ", LOG_TAG,val); + ret = hci_fm_set_notch_filter_req(val); + if (ret < 0) { + goto END; + } + break; + case HCI_FM_HELIUM_RDSD_BUF: radio->rds_grp.rds_buf_size = val; break; diff --git a/helium/radio_helium_hal_cmds.c b/helium/radio_helium_hal_cmds.c index 8e69e4b..1d422d1 100644 --- a/helium/radio_helium_hal_cmds.c +++ b/helium/radio_helium_hal_cmds.c @@ -161,6 +161,34 @@ int hci_fm_set_recv_conf_req (struct hci_fm_recv_conf_req *conf) return send_fm_cmd_pkt(opcode, sizeof((*conf)), conf); } +int hci_fm_get_program_service_req () +{ + uint16_t opcode = 0; + + opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, + HCI_OCF_FM_GET_PROGRAM_SERVICE_REQ); + return send_fm_cmd_pkt(opcode, 0, NULL); +} + +int hci_fm_get_rds_grpcounters_req (int val) +{ + uint16_t opcode = 0; + + opcode = hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, + HCI_OCF_FM_READ_GRP_COUNTERS); + return send_fm_cmd_pkt(opcode, sizeof(val), &val); +} + +int hci_fm_set_notch_filter_req (int val) +{ + uint16_t opcode = 0; + + opcode = hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, + HCI_OCF_FM_EN_NOTCH_CTRL); + return send_fm_cmd_pkt(opcode, sizeof(val), &val); +} + + int helium_set_sig_threshold_req(char th) { uint16_t opcode = 0; diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp index a410eb6..36199f6 100644 --- a/jni/android_hardware_fm.cpp +++ b/jni/android_hardware_fm.cpp @@ -101,6 +101,7 @@ typedef void (*rt_plus_cb)(char *rt_plus); typedef void (*ert_cb)(char *ert); typedef void (*disable_cb)(); typedef void (*callback_thread_event)(unsigned int evt); +typedef void (*rds_grp_cntrs_cb)(char *rds_params); static JNIEnv *mCallbackEnv = NULL; @@ -307,6 +308,11 @@ void fm_ert_update_cb(char *ert) mCallbackEnv->DeleteLocalRef(ert_buff); } +void rds_grp_cntrs_rsp_cb(char * evt_buffer) +{ + ALOGE("rds_grp_cntrs_rsp_cb"); +} + void fm_disabled_cb() { ALOGE("DISABLE"); @@ -348,6 +354,7 @@ typedef struct { rt_plus_cb rt_plus_update_cb; ert_cb ert_update_cb; disable_cb disabled_cb; + rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb; callback_thread_event thread_evt_cb; } fm_vendor_callbacks_t; @@ -375,6 +382,7 @@ static fm_vendor_callbacks_t fm_callbacks = { fm_rt_plus_update_cb, fm_ert_update_cb, fm_disabled_cb, + rds_grp_cntrs_rsp_cb, fm_thread_evt_cb }; @@ -1428,7 +1436,6 @@ int register_android_hardware_fm_fmradio(JNIEnv* env) } } // end namespace - jint JNI_OnLoad(JavaVM *jvm, void *reserved) { JNIEnv *e; -- GitLab