fm: Return frequency value in getFrequency
Return frequency value in getFrequency if call to function is successful
instead of error value.
Change-Id: I07d62aecbfc396ec94f4b1efb8fd096499a7e3bb
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_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 @@
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 @@
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 {
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;