Loading core/jni/android_hardware_fm_wl1271.cpp +88 −56 Original line number Diff line number Diff line Loading @@ -42,9 +42,14 @@ int setFreq(int freq); int radioOn(); int radioOff(); int setBand(int iLow, int iHigh); int HexStr2Int(const char* szHexStr); int getFreq(); bool radioEnabled = false; static int lastFreq = 0; static int giLow = 87500; static int giStep = 100; int radioOn() { Loading Loading @@ -122,48 +127,36 @@ int setFreq(int freq) return FM_JNI_SUCCESS; } using namespace android; /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_setControlNative (JNIEnv * env, jobject thiz, jint fd, jint id, jint value) int setBand(int iLow, int iHigh) { switch (value) { case 1: return radioOn(); break; case 2: return radioOff(); break; case 3: // mute not used break; case 4: // unmute if (system("hcitool cmd 0x3f 0x135 0x11 0x02 0x00 0x00 0x00") < 0) { return FM_JNI_FAILURE; if (iLow == 76000) { // Japan system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x01"); giLow = iLow; } else { system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x00"); } break; if (iLow == 87500 && iHigh == 107900) { // spacing 200kHz for north america system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x04"); giStep = 200; } else { // spacing 100kHz system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x02"); } return FM_JNI_SUCCESS; } static int HexStr2Int(const char* szHexStr) int HexStr2Int(const char* szHexStr) { unsigned long Result; sscanf(szHexStr, "%lx", &Result); return Result; } /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_getFreqNative (JNIEnv * env, jobject thiz, jint fd) { int getFreq(){ FILE *pRunPipe=NULL; char sAux[200]; char sLow[3]; Loading Loading @@ -195,7 +188,44 @@ char sResult[5]; } else return FM_JNI_FAILURE; } using namespace android; /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_setControlNative (JNIEnv * env, jobject thiz, jint fd, jint id, jint value) { switch (value) { case 1: return radioOn(); break; case 2: return radioOff(); break; case 3: // mute not used break; case 4: // unmute if (system("hcitool cmd 0x3f 0x135 0x11 0x02 0x00 0x00 0x00") < 0) { return FM_JNI_FAILURE; } break; } return FM_JNI_SUCCESS; } /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_getFreqNative (JNIEnv * env, jobject thiz, jint fd) { return getFreq(); } /*native interface */ Loading Loading @@ -230,11 +260,28 @@ static jint android_hardware_fmradio_FmReceiverJNI_getControlNative static jint android_hardware_fmradio_FmReceiverJNI_startSearchNative (JNIEnv * env, jobject thiz, jint fd, jint dir) { int retval = system("hcitool cmd 0x3f 0x135 0x0f 0x02 0x00 0x00 0x10"); int iCurrentFreq; // Added in order to move before seek and control all the FM Limits depending on the country iCurrentFreq = getFreq(); if(dir == 0) retval = system("hcitool cmd 0x3f 0x135 0x1b 0x02 0x00 0x00 0x01"); { if(iCurrentFreq == giLow) iCurrentFreq = 18000 + giStep; setFreq(iCurrentFreq-giStep); } else { if(iCurrentFreq == 17900) iCurrentFreq = giLow - giStep; setFreq(iCurrentFreq+giStep); } int retval = system("hcitool cmd 0x3f 0x135 0x0f 0x02 0x00 0x00 0x10"); if (dir == 0) retval = system("hcitool cmd 0x3f 0x135 0x1b 0x02 0x00 0x00 0x00"); else retval = system("hcitool cmd 0x3f 0x135 0x1b 0x02 0x00 0x00 0x01"); retval = system("hcitool cmd 0x3f 0x135 0x2d 0x02 0x00 0x00 0x02"); LOGD("startSearchNative() %d", retval); Loading Loading @@ -265,22 +312,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_getRSSINative static jint android_hardware_fmradio_FmReceiverJNI_setBandNative (JNIEnv * env, jobject thiz, jint fd, jint low, jint high) { if (low == 76000) { // Japan system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x01"); } else { system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x00"); } if (low == 87500 && high == 107900) { // spacing 200kHz for north america system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x04"); } else { // spacing 100kHz system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x02"); } return FM_JNI_SUCCESS; return setBand(low,high); } /* native interface */ Loading Loading
core/jni/android_hardware_fm_wl1271.cpp +88 −56 Original line number Diff line number Diff line Loading @@ -42,9 +42,14 @@ int setFreq(int freq); int radioOn(); int radioOff(); int setBand(int iLow, int iHigh); int HexStr2Int(const char* szHexStr); int getFreq(); bool radioEnabled = false; static int lastFreq = 0; static int giLow = 87500; static int giStep = 100; int radioOn() { Loading Loading @@ -122,48 +127,36 @@ int setFreq(int freq) return FM_JNI_SUCCESS; } using namespace android; /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_setControlNative (JNIEnv * env, jobject thiz, jint fd, jint id, jint value) int setBand(int iLow, int iHigh) { switch (value) { case 1: return radioOn(); break; case 2: return radioOff(); break; case 3: // mute not used break; case 4: // unmute if (system("hcitool cmd 0x3f 0x135 0x11 0x02 0x00 0x00 0x00") < 0) { return FM_JNI_FAILURE; if (iLow == 76000) { // Japan system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x01"); giLow = iLow; } else { system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x00"); } break; if (iLow == 87500 && iHigh == 107900) { // spacing 200kHz for north america system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x04"); giStep = 200; } else { // spacing 100kHz system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x02"); } return FM_JNI_SUCCESS; } static int HexStr2Int(const char* szHexStr) int HexStr2Int(const char* szHexStr) { unsigned long Result; sscanf(szHexStr, "%lx", &Result); return Result; } /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_getFreqNative (JNIEnv * env, jobject thiz, jint fd) { int getFreq(){ FILE *pRunPipe=NULL; char sAux[200]; char sLow[3]; Loading Loading @@ -195,7 +188,44 @@ char sResult[5]; } else return FM_JNI_FAILURE; } using namespace android; /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_setControlNative (JNIEnv * env, jobject thiz, jint fd, jint id, jint value) { switch (value) { case 1: return radioOn(); break; case 2: return radioOff(); break; case 3: // mute not used break; case 4: // unmute if (system("hcitool cmd 0x3f 0x135 0x11 0x02 0x00 0x00 0x00") < 0) { return FM_JNI_FAILURE; } break; } return FM_JNI_SUCCESS; } /* native interface */ static jint android_hardware_fmradio_FmReceiverJNI_getFreqNative (JNIEnv * env, jobject thiz, jint fd) { return getFreq(); } /*native interface */ Loading Loading @@ -230,11 +260,28 @@ static jint android_hardware_fmradio_FmReceiverJNI_getControlNative static jint android_hardware_fmradio_FmReceiverJNI_startSearchNative (JNIEnv * env, jobject thiz, jint fd, jint dir) { int retval = system("hcitool cmd 0x3f 0x135 0x0f 0x02 0x00 0x00 0x10"); int iCurrentFreq; // Added in order to move before seek and control all the FM Limits depending on the country iCurrentFreq = getFreq(); if(dir == 0) retval = system("hcitool cmd 0x3f 0x135 0x1b 0x02 0x00 0x00 0x01"); { if(iCurrentFreq == giLow) iCurrentFreq = 18000 + giStep; setFreq(iCurrentFreq-giStep); } else { if(iCurrentFreq == 17900) iCurrentFreq = giLow - giStep; setFreq(iCurrentFreq+giStep); } int retval = system("hcitool cmd 0x3f 0x135 0x0f 0x02 0x00 0x00 0x10"); if (dir == 0) retval = system("hcitool cmd 0x3f 0x135 0x1b 0x02 0x00 0x00 0x00"); else retval = system("hcitool cmd 0x3f 0x135 0x1b 0x02 0x00 0x00 0x01"); retval = system("hcitool cmd 0x3f 0x135 0x2d 0x02 0x00 0x00 0x02"); LOGD("startSearchNative() %d", retval); Loading Loading @@ -265,22 +312,7 @@ static jint android_hardware_fmradio_FmReceiverJNI_getRSSINative static jint android_hardware_fmradio_FmReceiverJNI_setBandNative (JNIEnv * env, jobject thiz, jint fd, jint low, jint high) { if (low == 76000) { // Japan system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x01"); } else { system("hcitool cmd 0x3f 0x135 0x10 0x02 0x00 0x00 0x00"); } if (low == 87500 && high == 107900) { // spacing 200kHz for north america system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x04"); } else { // spacing 100kHz system("hcitool cmd 0x3f 0x135 0x38 0x02 0x00 0x00 0x02"); } return FM_JNI_SUCCESS; return setBand(low,high); } /* native interface */ Loading