From 31bed2c7e252d1ec9a69cdc5c5c06af9e21db37d Mon Sep 17 00:00:00 2001 From: Kamal Negi <kamaln@codeaurora.org> Date: Thu, 6 Oct 2016 10:47:19 +0530 Subject: [PATCH] fm: Return frequency value in getFrequency Return frequency value in getFrequency if call to function is successful instead of error value. Change-Id: I07d62aecbfc396ec94f4b1efb8fd096499a7e3bb --- helium/radio-helium.h | 2 +- helium/radio_helium_hal.c | 20 ++++++++++++++------ jni/android_hardware_fm.cpp | 20 +++++++++++++------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/helium/radio-helium.h b/helium/radio-helium.h index a67c981..070dafa 100644 --- a/helium/radio-helium.h +++ b/helium/radio-helium.h @@ -1241,7 +1241,7 @@ struct fm_hal_t { struct fm_interface_t { int (*init)(const fm_hal_callbacks_t *p_cb); int (*set_fm_ctrl)(int opcode, int val); - void (*Get_fm_ctrl) (int opcode, int val); + void (*get_fm_ctrl) (int opcode, int *val); }; #endif /* __UAPI_RADIO_HCI_CORE_H */ diff --git a/helium/radio_helium_hal.c b/helium/radio_helium_hal.c index 733c0a5..3f68812 100644 --- a/helium/radio_helium_hal.c +++ b/helium/radio_helium_hal.c @@ -1612,7 +1612,7 @@ end: return ret; } -static int get_fm_ctrl(int cmd, int val) +static int get_fm_ctrl(int cmd, int *val) { int ret = 0; struct hci_fm_def_data_rd_req def_data_rd; @@ -1625,17 +1625,25 @@ static int get_fm_ctrl(int cmd, int val) ALOGE("%s: cmd = 0x%x", __func__, cmd); switch(cmd) { case HCI_FM_HELIUM_FREQ: - val = hal->radio->fm_st_rsp.station_rsp.station_freq; + if (!val) + return -FM_HC_STATUS_NULL_POINTER; + *val = hal->radio->fm_st_rsp.station_rsp.station_freq; break; case HCI_FM_HELIUM_UPPER_BAND: - val = hal->radio->recv_conf.band_high_limit; + if (!val) + return -FM_HC_STATUS_NULL_POINTER; + *val = hal->radio->recv_conf.band_high_limit; break; case HCI_FM_HELIUM_LOWER_BAND: - val = hal->radio->recv_conf.band_low_limit; + if (!val) + return -FM_HC_STATUS_NULL_POINTER; + *val = hal->radio->recv_conf.band_low_limit; break; case HCI_FM_HELIUM_AUDIO_MUTE: - val = hal->radio->mute_mode.hard_mute; - return val; + if (!val) + return -FM_HC_STATUS_NULL_POINTER; + *val = hal->radio->mute_mode.hard_mute; + break; case HCI_FM_HELIUM_SINR_SAMPLES: set_bit(ch_det_th_mask_flag, CMD_CHDET_SINR_SAMPLE); ret = hci_fm_get_ch_det_th(); diff --git a/jni/android_hardware_fm.cpp b/jni/android_hardware_fm.cpp index d4d4e15..9e469ed 100644 --- a/jni/android_hardware_fm.cpp +++ b/jni/android_hardware_fm.cpp @@ -513,7 +513,7 @@ typedef struct { typedef struct { int (*hal_init)(fm_vendor_callbacks_t *p_cb); int (*set_fm_ctrl)(int ioctl, int val); - int (*get_fm_ctrl) (int ioctl, int val); + int (*get_fm_ctrl) (int ioctl, int *val); } fm_interface_t; fm_interface_t *vendor_interface; @@ -652,7 +652,13 @@ static jint android_hardware_fmradio_FmReceiverJNI_getFreqNative int err; long freq; #ifdef FM_SOC_TYPE_CHEROKEE - err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_FREQ, freq); + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_FREQ, (int *)&freq); + if (err == FM_JNI_SUCCESS) { + err = freq; + } else { + err = FM_JNI_FAILURE; + ALOGE("%s: get freq failed\n", LOG_TAG); + } #else if (fd >= 0) { err = FmIoctlsInterface :: get_cur_freq(fd, freq); @@ -752,7 +758,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_getControlNative ALOGE("id(%x)\n", id); #ifdef FM_SOC_TYPE_CHEROKEE - err = vendor_interface->get_fm_ctrl(id, val); + err = vendor_interface->get_fm_ctrl(id, (int *)&val); if (err < 0) { ALOGE("%s: get control failed, id: %d\n", LOG_TAG, id); err = FM_JNI_FAILURE; @@ -850,7 +856,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_getRSSINative long rmssi; #ifdef FM_SOC_TYPE_CHEROKEE - err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_RMSSI, rmssi); + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_RMSSI, (int *)&rmssi); if (err < 0) { ALOGE("%s: Get Rssi failed", LOG_TAG); err = FM_JNI_FAILURE; @@ -920,7 +926,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_getLowerBandNative int err; ULINT freq; #ifdef FM_SOC_TYPE_CHEROKEE - err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_LOWER_BAND, freq); + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_LOWER_BAND, (int *)&freq); if (err < 0) { ALOGE("%s: get lower band failed\n", LOG_TAG); err = FM_JNI_FAILURE; @@ -954,7 +960,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_getUpperBandNative ULINT freq; #ifdef FM_SOC_TYPE_CHEROKEE - err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_UPPER_BAND, freq); + err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_UPPER_BAND, (int *)&freq); if (err < 0) { ALOGE("%s: get upper band failed\n", LOG_TAG); err = FM_JNI_FAILURE; @@ -985,7 +991,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_setMonoStereoNative int err; #ifdef FM_SOC_TYPE_CHEROKEE - err = vendor_interface->get_fm_ctrl(V4L2_CID_PRV_IRIS_AUDIO_MODE, val); + err = vendor_interface->set_fm_ctrl(V4L2_CID_PRV_IRIS_AUDIO_MODE, val); if (err < 0) { ALOGE("%s: set audio mode failed\n", LOG_TAG); err = FM_JNI_FAILURE; -- GitLab