diff --git a/helium/radio-helium-commands.h b/helium/radio-helium-commands.h index 3c9bbdca87c57a6ba213643054db221feea800f5..352017e2a8356e9448dc9c3e4b2ab7170c3d9875 100644 --- a/helium/radio-helium-commands.h +++ b/helium/radio-helium-commands.h @@ -97,6 +97,8 @@ enum helium_cmd_t { HCI_FM_HELIUM_AF_JUMP_RSSI_TH, HCI_FM_HELIUM_BLEND_SINRHI, HCI_FM_HELIUM_BLEND_RMSSIHI, + HCI_FM_HELIUM_AGC_UCCTRL = 0x8000043, /* 0x8000043 */ + HCI_FM_HELIUM_AGC_GAIN_STATE, /*using private CIDs under userclass*/ HCI_FM_HELIUM_READ_DEFAULT = 0x00980928, diff --git a/helium/radio-helium.h b/helium/radio-helium.h index 989bb559e5e14f69f274726d963c82a026963d57..cb72cd557f13ec767f3ea97a20ea710f130afdc1 100644 --- a/helium/radio-helium.h +++ b/helium/radio-helium.h @@ -166,6 +166,7 @@ typedef void (*callback_thread_event)(unsigned int evt); typedef void (*rds_grp_cntrs_cb)(char *rds_params); typedef void (*fm_peek_cb)(char *peek_rsp); typedef void (*fm_ssbi_peek_cb)(char *ssbi_peek_rsp); +typedef void (*fm_agc_gain_cb)(char *agc_gain_rsp); typedef void (*fm_ch_det_th_cb)(char *ch_det_rsp); typedef void (*fm_ecc_evt_cb)(char *ecc_rsp); typedef void (*fm_sig_thr_cb) (int val, int status); @@ -198,6 +199,7 @@ typedef struct { rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb; fm_peek_cb fm_peek_rsp_cb; fm_ssbi_peek_cb fm_ssbi_peek_rsp_cb; + fm_agc_gain_cb fm_agc_gain_rsp_cb; fm_ch_det_th_cb fm_ch_det_th_rsp_cb; fm_ecc_evt_cb ext_country_code_cb; callback_thread_event thread_evt_cb; @@ -309,6 +311,7 @@ struct radio_hci_dev { #define HCI_OCF_FM_SSBI_POKE_REG 0x0005 #define HCI_OCF_FM_STATION_DBG_PARAM 0x0007 #define HCI_FM_SET_INTERNAL_TONE_GENRATOR 0x0008 +#define HCI_FM_SET_GET_RESET_AGC 0x000D /* Opcode OGF */ #define HCI_OGF_FM_RECV_CTRL_CMD_REQ 0x0013 @@ -319,20 +322,19 @@ struct radio_hci_dev { #define HCI_OGF_FM_DIAGNOSTIC_CMD_REQ 0x003F /* Command opcode pack/unpack */ -#define hci_opcode_pack(ogf, ocf) (short) ((ocf & 0x03ff)|(ogf << 10)) +#define hci_opcode_pack(ogf, ocf) (uint16_t) (((ocf) & 0x03ff)|((ogf) << 10)) #define hci_opcode_ogf(op) (op >> 10) #define hci_opcode_ocf(op) (op & 0x03ff) #define hci_recv_ctrl_cmd_op_pack(ocf) \ - (short) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf) + (uint16_t) hci_opcode_pack(HCI_OGF_FM_RECV_CTRL_CMD_REQ, ocf) #define hci_trans_ctrl_cmd_op_pack(ocf) \ - (short) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf) + (uint16_t) hci_opcode_pack(HCI_OGF_FM_TRANS_CTRL_CMD_REQ, ocf) #define hci_common_cmd_op_pack(ocf) \ - (short) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf) + (uint16_t) hci_opcode_pack(HCI_OGF_FM_COMMON_CTRL_CMD_REQ, ocf) #define hci_status_param_op_pack(ocf) \ - (short) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf) + (uint16_t) hci_opcode_pack(HCI_OGF_FM_STATUS_PARAMETERS_CMD_REQ, ocf) #define hci_diagnostic_cmd_op_pack(ocf) \ - (short) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf) - + (uint16_t) hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, ocf) /* HCI commands with no arguments*/ #define HCI_FM_ENABLE_RECV_CMD 1 @@ -484,6 +486,11 @@ struct hci_fm_ssbi_peek { short start_address; } ; +struct hci_fm_set_get_reset_agc { + char ucctrl; + char ucgainstate; +} ; + struct hci_fm_ch_det_threshold { char sinr; char sinr_samples; @@ -1195,6 +1202,7 @@ struct helium_device { struct hci_fm_riva_poke riva_data_req; struct hci_fm_ssbi_req ssbi_data_accs; struct hci_fm_ssbi_peek ssbi_peek_reg; + struct hci_fm_set_get_reset_agc set_get_reset_agc; struct hci_fm_ch_det_threshold ch_det_threshold; struct hci_fm_data_rd_rsp def_data; struct hci_fm_blend_table blend_tbl; @@ -1255,6 +1263,7 @@ int hci_peek_data(struct hci_fm_riva_data *data); int hci_poke_data(struct hci_fm_riva_poke *data); int hci_ssbi_poke_reg(struct hci_fm_ssbi_req *data); int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *data); +int hci_get_set_reset_agc_req(struct hci_fm_set_get_reset_agc *data); int hci_fm_get_ch_det_th(); 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); diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c index 5437bad9a587292bc3e99fe0e761277cac2f0eae..2412b426fec4d8fdc571e236f2299d8f43095d7e 100644 --- a/helium/radio_helium_hal.c +++ b/helium/radio_helium_hal.c @@ -192,6 +192,24 @@ static void hci_cc_ssbi_peek_rsp(char *ev_buff) radio_hci_req_complete(status); } +static void hci_cc_agc_rsp(char *ev_buff) +{ + char status; + ALOGV("inside hci_cc_agc_rsp"); + if (ev_buff == NULL) { + ALOGE("%s:%s, buffer is null\n", LOG_TAG, __func__); + return; + } + status = ev_buff[0]; + ALOGV("%s:%s, status =%d\n", LOG_TAG, __func__,status); + if (status != 0) { + ALOGE("%s:%s,agc gain failed=%d\n", LOG_TAG, __func__, status); + } else { + jni_cb->fm_agc_gain_rsp_cb(&ev_buff[1]); + } + radio_hci_req_complete(status); +} + static void hci_cc_get_ch_det_threshold_rsp(char *ev_buff) { int status; @@ -378,9 +396,9 @@ static inline void hci_cmd_complete_event(char *buff) ALOGE("%s:%s, buffer is null\n", LOG_TAG, __func__); return; } - ALOGE("%s:buff[1] = 0x%x buff[2] = 0x%x", LOG_TAG, buff[1], buff[2]); + ALOGV("%s:buff[1] = 0x%x buff[2] = 0x%x", LOG_TAG, buff[1], buff[2]); opcode = ((buff[2] << 8) | buff[1]); - ALOGE("%s: Received HCI CMD COMPLETE EVENT for opcode: 0x%x", __func__, opcode); + ALOGV("%s: Received HCI CMD COMPLETE EVENT for the opcode: 0x%x", __func__, opcode); pbuf = &buff[3]; switch (opcode) { @@ -428,6 +446,9 @@ static inline void hci_cmd_complete_event(char *buff) case hci_diagnostic_cmd_op_pack(HCI_OCF_FM_SSBI_PEEK_REG): hci_cc_ssbi_peek_rsp(buff); break; + case hci_diagnostic_cmd_op_pack(HCI_FM_SET_GET_RESET_AGC): + hci_cc_agc_rsp(pbuf); + break; case hci_recv_ctrl_cmd_op_pack(HCI_OCF_FM_GET_CH_DET_THRESHOLD): hci_cc_get_ch_det_threshold_rsp(pbuf); break; @@ -1128,7 +1149,6 @@ static int set_fm_ctrl(int cmd, int val) char *data; struct hci_fm_def_data_wr_req def_data_wrt; - ALOGE("%s:cmd: %x, val: %d",LOG_TAG, cmd, val); switch (cmd) { @@ -1384,6 +1404,13 @@ static int set_fm_ctrl(int cmd, int val) radio->ssbi_peek_reg.start_address = val; hci_ssbi_peek_reg(&radio->ssbi_peek_reg); break; + case HCI_FM_HELIUM_AGC_UCCTRL: + radio->set_get_reset_agc.ucctrl = val; + break; + case HCI_FM_HELIUM_AGC_GAIN_STATE: + radio->set_get_reset_agc.ucgainstate = val; + hci_get_set_reset_agc_req(&radio->set_get_reset_agc); + break; case HCI_FM_HELIUM_SINR_SAMPLES: if (!is_valid_sinr_samples(val)) { ALOGE("%s: sinr samples count is not valid\n", __func__); diff --git a/helium/radio_helium_hal_cmds.c b/helium/radio_helium_hal_cmds.c index ea0b3c26791727db21123f3ba720ecaca112112e..f9c307a144f33363b53c4cb9c4cc014916a9dff0 100644 --- a/helium/radio_helium_hal_cmds.c +++ b/helium/radio_helium_hal_cmds.c @@ -42,7 +42,7 @@ static int send_fm_cmd_pkt(uint16_t opcode, uint32_t len, void *param) { int p_len = 4 + len; int ret = 0; - + ALOGV("Send_fm_cmd_pkt, opcode: %x", opcode); // pthread_mutex_lock(&fm_hal); FM_HDR *hdr = (FM_HDR *) malloc(p_len); if (!hdr) { @@ -333,6 +333,18 @@ int hci_ssbi_peek_reg(struct hci_fm_ssbi_peek *data) return send_fm_cmd_pkt(opcode, sizeof((*data)), data); } +int hci_get_set_reset_agc_req(struct hci_fm_set_get_reset_agc *data) +{ + uint16_t opcode = 0; + if (data == NULL) { + ALOGE("%s:%s,AGC set get reset req is null\n", LOG_TAG, __func__); + return -EINVAL; + } + opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ, + HCI_FM_SET_GET_RESET_AGC); + return send_fm_cmd_pkt(opcode, sizeof((*data)), data); +} + int hci_fm_get_ch_det_th() { ALOGV("%s", __func__); diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp index d1857e4ffacc268c674ba37600dce10150fa154b..dd439fc291494604fcff56263de5d7d616ae28cb 100644 --- a/jni/android_hardware_fm.cpp +++ b/jni/android_hardware_fm.cpp @@ -106,6 +106,7 @@ typedef void (*callback_thread_event)(unsigned int evt); typedef void (*rds_grp_cntrs_cb)(char *rds_params); typedef void (*fm_peek_cb)(char *peek_rsp); typedef void (*fm_ssbi_peek_cb)(char *ssbi_peek_rsp); +typedef void (*fm_agc_gain_cb)(char *agc_gain_rsp); typedef void (*fm_ch_det_th_cb)(char *ch_det_rsp); typedef void (*fm_ecc_evt_cb)(char *ecc); typedef void (*fm_sig_thr_cb)(int val, int status); @@ -376,6 +377,10 @@ void fm_ssbi_peek_rsp_cb(char *ssbi_peek_rsp){ ALOGD("fm_ssbi_peek_rsp_cb"); } +void fm_agc_gain_rsp_cb(char *agc_gain_rsp){ + ALOGE("fm_agc_gain_rsp_cb"); +} + void fm_ch_det_th_rsp_cb(char *ch_det_rsp){ ALOGD("fm_ch_det_th_rsp_cb"); } @@ -482,6 +487,7 @@ typedef struct { rds_grp_cntrs_cb rds_grp_cntrs_rsp_cb; fm_peek_cb fm_peek_rsp_cb; fm_ssbi_peek_cb fm_ssbi_peek_rsp_cb; + fm_agc_gain_cb fm_agc_gain_rsp_cb; fm_ch_det_th_cb fm_ch_det_th_rsp_cb; fm_ecc_evt_cb ext_country_code_cb; callback_thread_event thread_evt_cb; @@ -523,6 +529,7 @@ static fm_vendor_callbacks_t fm_callbacks = { rds_grp_cntrs_rsp_cb, fm_peek_rsp_cb, fm_ssbi_peek_rsp_cb, + fm_agc_gain_rsp_cb, fm_ch_det_th_rsp_cb, fm_ext_country_code_cb, fm_thread_evt_cb,