1 /* 2 * 3 * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/ 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #include "android_runtime/AndroidRuntime.h" 19 #include "jni.h" 20 #include "JNIHelp.h" 21 #include "v4l2_JbtlLog.h" 22 23 24 #define LOG_TAG "JFmRxNative" 25 #include <cutils/properties.h> 26 27 using namespace android; 28 29 extern "C" { 30 #include <stdio.h> 31 #include <stdlib.h> 32 #include <fcntl.h> 33 #include <asoundlib.h> 34 #include <linux/videodev.h> 35 #include <math.h> 36 #include <pthread.h> 37 #include <errno.h> 38 #include <string.h> 39 #include <poll.h> 40 41 #include "JFmRxNative.h" 42 43 /*Callback for FM commands*/ 44 void nativeJFmRx_Callback(long context, int status, 45 int command, long value); 46 47 /*Callback for FM PS*/ 48 49 50 void nativeJFmRx_PS_Callback(long context,int status, int freq, 51 int len,unsigned char * name, 52 int repertoire) ; 53 54 /*Callback for FM Radio Text*/ 55 56 void nativeJFmRx_RadioText_Callback(int status, bool resetDisplay, 57 unsigned char * msg, int len, int startIndex, 58 int repertoire) ; 59 } //extern "C" 60 61 static JavaVM *g_jVM = NULL; 62 static jclass _sJClass; 63 64 typedef pthread_t THREAD_HANDLE; 65 THREAD_HANDLE p_threadHandle; /* Thread Handle for RDS data */ 66 static bool isThreadCreated = false; 67 static int radio_fd; 68 //snd_ctl_t *fm_snd_ctrl; 69 long jContext; 70 volatile bool g_stopCommListener = false; 71 72 static int chanl_spacing=200000; 73 74 /* Complete parsing of the RDS data has not been implemented yet 75 Commented the FM RX RDS callbacks functionality start*/ 76 77 #if 0 78 static jmethodID _sMethodId_nativeCb_fmRxRawRDS; 79 static jmethodID _sMethodId_nativeCb_fmRxPiCodeChanged; 80 static jmethodID _sMethodId_nativeCb_fmRxPtyCodeChanged; 81 static jmethodID _sMethodId_nativeCb_fmRxMonoStereoModeChanged; 82 static jmethodID _sMethodId_nativeCb_fmRxAudioPathChanged; 83 static jmethodID _sMethodId_nativeCb_fmRxAfSwitchFreqFailed; 84 static jmethodID _sMethodId_nativeCb_fmRxAfSwitchStart; 85 static jmethodID _sMethodId_nativeCb_fmRxAfSwitchComplete; 86 static jmethodID _sMethodId_nativeCb_fmRxAfListChanged; 87 static jmethodID _sMethodId_nativeCb_fmRxCompleteScanDone; 88 #endif 89 90 /*Commented the FM RX RDS callbacks functionality end*/ 91 92 93 static jmethodID _sMethodId_nativeCb_fmRxPsChanged; 94 static jmethodID _sMethodId_nativeCb_fmRxRadioText; 95 static jmethodID _sMethodId_nativeCb_fmRxCmdEnable; 96 static jmethodID _sMethodId_nativeCb_fmRxCmdDisable; 97 98 static jmethodID _sMethodId_nativeCb_fmRxCmdEnableAudio; 99 static jmethodID _sMethodId_nativeCb_fmRxCmdChangeAudioTarget; 100 static jmethodID _sMethodId_nativeCb_fmRxCmdSetBand; 101 static jmethodID _sMethodId_nativeCb_fmRxCmdGetBand; 102 static jmethodID _sMethodId_nativeCb_fmRxCmdSetMonoStereoMode; 103 static jmethodID _sMethodId_nativeCb_fmRxCmdGetMonoStereoMode; 104 static jmethodID _sMethodId_nativeCb_fmRxCmdGetMuteMode; 105 static jmethodID _sMethodId_nativeCb_fmRxCmdSetMuteMode; 106 static jmethodID _sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode; 107 static jmethodID _sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode; 108 static jmethodID _sMethodId_nativeCb_fmRxCmdSetRssiThreshhold; 109 static jmethodID _sMethodId_nativeCb_fmRxCmdGetRssiThreshhold; 110 static jmethodID _sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter; 111 static jmethodID _sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter; 112 static jmethodID _sMethodId_nativeCb_fmRxCmdSetVolume; 113 static jmethodID _sMethodId_nativeCb_fmRxCmdGetVolume; 114 static jmethodID _sMethodId_nativeCb_fmRxCmdGetChannelSpacing; 115 static jmethodID _sMethodId_nativeCb_fmRxCmdSetChannelSpacing; 116 static jmethodID _sMethodId_nativeCb_fmRxCmdTune; 117 static jmethodID _sMethodId_nativeCb_fmRxCmdGetTunedFrequency; 118 static jmethodID _sMethodId_nativeCb_fmRxCmdSeek; 119 static jmethodID _sMethodId_nativeCb_fmRxCmdStopSeek; 120 static jmethodID _sMethodId_nativeCb_fmRxCmdGetRssi; 121 static jmethodID _sMethodId_nativeCb_fmRxCmdEnableRds; 122 static jmethodID _sMethodId_nativeCb_fmRxCmdDisableRds; 123 static jmethodID _sMethodId_nativeCb_fmRxCmdGetRdsSystem; 124 static jmethodID _sMethodId_nativeCb_fmRxCmdSetRdsSystem; 125 static jmethodID _sMethodId_nativeCb_fmRxCmdSetRdsGroupMask; 126 static jmethodID _sMethodId_nativeCb_fmRxCmdGetRdsGroupMask; 127 static jmethodID _sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode; 128 static jmethodID _sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode; 129 static jmethodID _sMethodId_nativeCb_fmRxCmdDisableAudio; 130 static jmethodID _sMethodId_nativeCb_fmRxCmdDestroy; 131 static jmethodID _sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration; 132 static jmethodID _sMethodId_nativeCb_fmRxCmdGetFwVersion; 133 static jmethodID _sMethodId_nativeCb_fmRxCmdIsValidChannel; 134 static jmethodID _sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress; 135 static jmethodID _sMethodId_nativeCb_fmRxCmdStopCompleteScan; 136 137 138 139 140 141 int rdsParseFunc_updateRepertoire(int byte1,int byte2) 142 { 143 144 int repertoire1,repertoire2; 145 int repertoire3,repertoire4; 146 int repertoire; 147 148 /*replace to nibble high/low*/ 149 repertoire1 = (FMC_U8)(byte1&RDS_BIT_0_TO_BIT_3); 150 repertoire2 = (FMC_U8)((byte1&RDS_BIT_4_TO_BIT_7)>>4); 151 repertoire3 = (FMC_U8)(byte2&RDS_BIT_0_TO_BIT_3); 152 repertoire4 = (FMC_U8)((byte2&RDS_BIT_4_TO_BIT_7)>>4); 153 154 if((repertoire2==0)&&(repertoire1==15)&&(repertoire4==0)&&(repertoire3==15)) 155 { 156 repertoire = FMC_RDS_REPERTOIRE_G0_CODE_TABLE; 157 158 } 159 else if((repertoire2==0)&&(repertoire1==14)&&(repertoire4==0)&&(repertoire3==14)) 160 { 161 repertoire = FMC_RDS_REPERTOIRE_G1_CODE_TABLE; 162 163 } 164 else if ((repertoire2==1)&&(repertoire1==11)&&(repertoire4==6)&&(repertoire3==14)) 165 { 166 repertoire = FMC_RDS_REPERTOIRE_G2_CODE_TABLE; 167 168 } 169 170 V4L2_JBTL_LOGD(" rdsParseFunc_updateRepertoire repertoire%d\n",repertoire); 171 return repertoire; 172 } 173 174 175 void rds_decode(int blkno, int byte1, int byte2) 176 { 177 static unsigned char rds_psn[9]; 178 static unsigned char rds_txt[65]; 179 static int rds_pty,ms_code; 180 static int group,spare,blkc_byte1,blkc_byte2; 181 int len; 182 bool resetDisplay =false; 183 int status = 0,startIndex=0,repertoire,freq; 184 185 switch (blkno) { 186 case 0: /* Block A */ 187 V4L2_JBTL_LOGD("block A - id=%d\n",(byte1 << 8) | byte2); 188 break; 189 case 1: /* Block B */ 190 V4L2_JBTL_LOGD("block B - group=%d%c tp=%d pty=%d spare=%d\n", 191 (byte1 >> 4) & 0x0f, 192 ((byte1 >> 3) & 0x01) + 'A', 193 (byte1 >> 2) & 0x01, 194 ((byte1 << 3) & 0x18) | ((byte2 >> 5) & 0x07), 195 byte2 & 0x1f); 196 group = (byte1 >> 3) & 0x1f; 197 spare = byte2 & 0x1f; 198 rds_pty = ((byte1 << 3) & 0x18) | ((byte2 >> 5) & 0x07); 199 ms_code = (byte2 >> 3)& 0x1; 200 201 break; 202 case 2: /* Block C */ 203 V4L2_JBTL_LOGD("block C - 0x%02x 0x%02x\n",byte1,byte2); 204 blkc_byte1 = byte1; 205 blkc_byte2 = byte2; 206 break; 207 case 3 : /* Block D */ 208 V4L2_JBTL_LOGD("block D - 0x%02x 0x%02x\n",byte1,byte2); 209 switch (group) { 210 case 0: /* Group 0A */ 211 rds_psn[2*(spare & 0x03)+0] = byte1; 212 rds_psn[2*(spare & 0x03)+1] = byte2; 213 if ((spare & 0x03) == 0x03) 214 { 215 V4L2_JBTL_LOGD("PSN: %s, PTY: %d, MS: %s\n",rds_psn, 216 rds_pty,ms_code?"Music":"Speech"); 217 218 len = strlen((const char *)rds_psn); 219 V4L2_JBTL_LOGD("PS len %d",len); 220 nativeJFmRx_PS_Callback(jContext,status,freq,len,rds_psn,repertoire); 221 } 222 223 break; 224 case 4: /* Group 2A */ 225 226 repertoire = rdsParseFunc_updateRepertoire(byte1,byte2); 227 228 repertoire =0; 229 230 V4L2_JBTL_LOGD("Radio repertoire: %d\n",repertoire); 231 rds_txt[4*(spare & 0x0f)+0] = blkc_byte1; 232 rds_txt[4*(spare & 0x0f)+1] = blkc_byte2; 233 rds_txt[4*(spare & 0x0f)+2] = byte1; 234 rds_txt[4*(spare & 0x0f)+3] = byte2; 235 /* Display radio text once we get 16 characters */ 236 if (spare > 16) 237 { 238 len =strlen((const char *)rds_txt); 239 240 V4L2_JBTL_LOGD("RDS len %d",len); 241 V4L2_JBTL_LOGD("Radio Text: %s\n",rds_txt); 242 243 nativeJFmRx_RadioText_Callback(status, resetDisplay, 244 rds_txt, len, startIndex,repertoire) ; 245 } 246 break; 247 } 248 V4L2_JBTL_LOGD("----------------------------------------\n"); 249 break; 250 default: 251 V4L2_JBTL_LOGD("unknown block [%d]\n",blkno); 252 } 253 } 254 255 /** 256 * Function: entryFunctionForRdsThread 257 * Brief: Creates a thread for waiting on responses from RDS . 258 * Description: 259 */ 260 261 void *entryFunctionForRdsThread(void *data) 262 { 263 unsigned char buf[600]; 264 int radio_fd; 265 int ret,index; 266 struct pollfd pfd; 267 268 radio_fd = (int)data; 269 270 V4L2_JBTL_LOGD(" entryFunctionForRdsThread: Entering.g_stopCommListener %d \n",g_stopCommListener); 271 272 while(!g_stopCommListener) 273 { 274 275 V4L2_JBTL_LOGD("RDS thread running..\n"); 276 277 while(1){ 278 memset(&pfd, 0, sizeof(pfd)); 279 pfd.fd = radio_fd; 280 pfd.events = POLLIN; 281 ret = poll(&pfd, 1, 10); 282 if (ret == 0){ 283 /* Break the poll after RDS data available */ 284 break; 285 } 286 } 287 288 ret = read(radio_fd,buf,500); 289 if(ret < 0) 290 { V4L2_JBTL_LOGD("NO RDS data to read..\n"); 291 return NULL; 292 } 293 294 else if( ret > 0) 295 { 296 297 V4L2_JBTL_LOGD(" RDS data to read is available..\n"); 298 for(index=0;index<ret;index+=3) 299 rds_decode(buf[index+2] & 0x7,buf[index+1],buf[index]); 300 } 301 } 302 303 V4L2_JBTL_LOGD("RDS thread exiting..\n"); 304 return NULL; 305 } 306 307 int fm_read_tuner_capabilities(int radio_fd) 308 { 309 struct v4l2_capability cap; 310 int res; 311 312 res = ioctl(radio_fd,VIDIOC_QUERYCAP,&cap); 313 if(res < 0) 314 { 315 V4L2_JBTL_LOGD("Failed to read %s capabilities\n",DEFAULT_RADIO_DEVICE); 316 return FM_FAILED; 317 } 318 if((cap.capabilities & V4L2_CAP_RADIO) == 0) 319 { 320 V4L2_JBTL_LOGD("%s is not radio devcie",DEFAULT_RADIO_DEVICE); 321 return FM_FAILED; 322 } 323 V4L2_JBTL_LOGD("\n***%s Info ****\n",DEFAULT_RADIO_DEVICE); 324 V4L2_JBTL_LOGD("Driver : %s\n",cap.driver); 325 V4L2_JBTL_LOGD("Card : %s\n",cap.card); 326 V4L2_JBTL_LOGD("Bus : %s\n",cap.bus_info); 327 V4L2_JBTL_LOGD("Capabilities : 0x%x\n",cap.capabilities); 328 329 return FM_SUCCESS; 330 } 331 332 333 static int nativeJFmRx_Create(JNIEnv *env,jobject obj,jobject jContextValue) 334 { 335 336 int fmStatus ; 337 338 V4L2_JBTL_LOGD("Java_JFmRx_nativeJFmRx_Create(): Entered"); 339 340 radio_fd = open(DEFAULT_RADIO_DEVICE, O_RDWR); 341 if(radio_fd < 0) 342 { 343 V4L2_JBTL_LOGD("Unable to open %s ..\n",DEFAULT_RADIO_DEVICE); 344 jniThrowIOException(env, errno); 345 return FM_FAILED; 346 } 347 348 fmStatus = fm_read_tuner_capabilities(radio_fd); 349 if(fmStatus< 0) 350 { 351 close(radio_fd); 352 return fmStatus; 353 } 354 355 V4L2_JBTL_LOGD("nativeJFmRx_create:Exiting Successfully"); 356 357 return fmStatus; 358 } 359 360 361 362 static int nativeJFmRx_Destroy(JNIEnv *env, jobject obj,jlong jContextValue) 363 { 364 365 V4L2_JBTL_LOGD("nativeJFmRx_destroy(): Entered"); 366 367 V4L2_JBTL_LOGD("nativeJFmRx_destroy(): Exit"); 368 return FM_SUCCESS; 369 } 370 371 372 373 static int nativeJFmRx_Enable(JNIEnv *env, jobject obj, jlong jContextValue) 374 { 375 376 int status ; 377 struct v4l2_tuner vtun; 378 379 V4L2_JBTL_LOGD("nativeJFmRx_enable(): Entered"); 380 381 jContext = jContextValue; 382 383 vtun.index = 0; 384 vtun.audmode = V4L2_TUNER_MODE_STEREO; 385 vtun.rxsubchans = V4L2_TUNER_SUB_RDS; 386 387 status = ioctl(radio_fd, VIDIOC_S_TUNER, &vtun); 388 if(status < 0) 389 { 390 V4L2_JBTL_LOGD("Failed to Enable FM\n"); 391 return status; 392 } 393 394 V4L2_JBTL_LOGD("nativeJFmRx_enable: FM_RX_Enable() returned %d",(int)status); 395 nativeJFmRx_Callback(jContext,status,FM_RX_CMD_ENABLE,status); 396 V4L2_JBTL_LOGD("nativeJFmRx_enable(): Exit"); 397 return status; 398 } 399 400 401 402 static int nativeJFmRx_Disable(JNIEnv *env, jobject obj, jlong jContextValue) 403 { 404 V4L2_JBTL_LOGD("nativeJFmRx_disable(): Entered"); 405 406 // Terminate RDS thread 407 g_stopCommListener = true; 408 isThreadCreated = false; 409 410 close(radio_fd); 411 nativeJFmRx_Callback(jContext,0,FM_RX_CMD_DISABLE,0); 412 413 V4L2_JBTL_LOGD("nativeJFmRx_disable(): Exit");; 414 return FM_SUCCESS; 415 } 416 417 418 419 static int nativeJFmRx_SetBand(JNIEnv *env, jobject obj,jlong jContextValue, jint jFmBand) 420 { 421 int status=0; 422 static unsigned char last_band = FM_BAND_EUROPE_US; 423 char curr_band; 424 int fd, res; 425 426 switch(jFmBand) { 427 case 1: 428 curr_band = '1'; 429 break; 430 case 0: 431 default: 432 curr_band = '0'; 433 break; 434 } 435 436 V4L2_JBTL_LOGD("nativeJFmRx_setBand(): EnteredjFmBand %d",jFmBand); 437 V4L2_JBTL_LOGD("nativeJFmRx_setBand(): curr_band %d last_band %d",curr_band,last_band); 438 439 fd = open(FM_BAND_SYSFS_ENTRY, O_RDWR); 440 if (fd < 0) { 441 V4L2_JBTL_LOGD("Can't open %s", FM_BAND_SYSFS_ENTRY); 442 return FM_FAILED; 443 } 444 445 res = write(fd, &curr_band, sizeof(char)); 446 if(res <= 0){ 447 V4L2_JBTL_LOGD("Failed to set FM Band\n"); 448 return FM_FAILED; 449 } 450 451 nativeJFmRx_Callback(jContext,status,FM_RX_CMD_SET_BAND,status); 452 453 V4L2_JBTL_LOGD("nativeJFmRx_setBand(): Exit"); 454 return FM_PENDING; 455 } 456 457 458 static int nativeJFmRx_GetBand(JNIEnv *env, jobject obj,jlong jContextValue) 459 { 460 461 int status = 0; 462 unsigned char curr_band; 463 464 nativeJFmRx_Callback(jContext,status,FM_RX_CMD_GET_BAND,curr_band); 465 466 V4L2_JBTL_LOGD("nativeJFmRx_getBand(): Exit"); 467 468 return FM_PENDING; 469 } 470 471 472 static int nativeJFmRx_Tune(JNIEnv *env, jobject obj,jlong jContextValue,jint user_freq) 473 { 474 struct v4l2_frequency vf; 475 struct v4l2_tuner vt; 476 int status, div; 477 478 V4L2_JBTL_LOGD("nativeJFmRx_tune(): Entered"); 479 480 vt.index = 0; 481 status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); 482 if(status < 0) 483 { 484 V4L2_JBTL_LOGD("Failed to get tuner capabilities\n"); 485 return FM_FAILED; 486 } 487 488 vf.tuner = 0; 489 vf.frequency = rint(user_freq * 16 + 0.5); 490 491 div = (vt.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; 492 if (div == 1) 493 vf.frequency /=1000; 494 495 status = ioctl(radio_fd, VIDIOC_S_FREQUENCY, &vf); 496 if(status < 0) 497 { 498 V4L2_JBTL_LOGD("Failed to tune to frequency %d\n",user_freq); 499 return FM_FAILED; 500 } 501 V4L2_JBTL_LOGD("Tuned to frequency %2.1f MHz\n",user_freq); 502 503 nativeJFmRx_Callback(jContext,status,FM_RX_CMD_TUNE,user_freq); 504 505 V4L2_JBTL_LOGD("nativeJFmRx_Tune(): Exit"); 506 return FM_PENDING; 507 508 509 510 } 511 512 513 static int nativeJFmRx_GetTunedFrequency(JNIEnv *env, jobject obj,jlong jContextValue) 514 { 515 struct v4l2_frequency vf; 516 int status; 517 V4L2_JBTL_LOGD("nativeJFmRx_getTunedFrequency(): Entered"); 518 519 status = ioctl(radio_fd, VIDIOC_G_FREQUENCY,&vf); 520 if(status < 0) 521 { 522 V4L2_JBTL_LOGD("Failed to read current frequency\n"); 523 return FM_FAILED; 524 } 525 526 V4L2_JBTL_LOGD("Tuned to frequency %2.1f MHz \n",(float)vf.frequency/1000); 527 nativeJFmRx_Callback(jContext,status,FM_RX_CMD_GET_TUNED_FREQUENCY,vf.frequency); 528 529 V4L2_JBTL_LOGD("nativeJFmRx_getTunedFrequency(): Exit"); 530 return FM_PENDING; 531 532 } 533 534 535 536 static int nativeJFmRx_SetMonoStereoMode(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmMode) 537 { 538 539 struct v4l2_tuner vt; 540 int status; 541 V4L2_JBTL_LOGD("nativeJFmRx_SetMonoStereoMode(): Entered"); 542 543 vt.index = 0; 544 vt.audmode = jFmMode; 545 546 status = ioctl(radio_fd, VIDIOC_S_TUNER, &vt); 547 if (status < 0){ 548 V4L2_JBTL_LOGD("Failed to set stereo/mono mode\n"); 549 return FM_FAILED; 550 } 551 552 V4L2_JBTL_LOGD("Set to %d Mode\n",jFmMode); 553 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_MONO_STEREO_MODE,status); 554 555 V4L2_JBTL_LOGD("nativeJFmRx_SetMonoStereoMode(): Exit"); 556 return FM_PENDING; 557 } 558 559 560 561 static int nativeJFmRx_GetMonoStereoMode(JNIEnv *env, jobject obj,jlong jContextValue) 562 { 563 struct v4l2_tuner vt; 564 int status; 565 unsigned char mode; 566 567 V4L2_JBTL_LOGD("nativeJFmRx_GetMonoStereoMode(): Entered"); 568 569 vt.index = 0; 570 status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); 571 if (status < 0){ 572 V4L2_JBTL_LOGD("Failed to get stereo/mono mode\n"); 573 return FM_FAILED; 574 } 575 mode = vt.audmode; 576 577 V4L2_JBTL_LOGD("%d mode\n",mode); 578 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_MONO_STEREO_MODE,mode); 579 580 V4L2_JBTL_LOGD("nativeJFmRx_GetMonoStereoMode(): Exit"); 581 return FM_PENDING ; 582 } 583 584 585 586 static int nativeJFmRx_SetMuteMode(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmMuteMode) 587 { 588 589 struct v4l2_control vctrl; 590 int status; 591 592 V4L2_JBTL_LOGD("nativeJFmRx_setMuteMode(): Entered"); 593 594 vctrl.id = V4L2_CID_AUDIO_MUTE; 595 vctrl.value = !jFmMuteMode; /* To Do:: Mapping in future for V4L2*/ 596 status = ioctl(radio_fd,VIDIOC_S_CTRL,&vctrl); 597 if(status < 0) 598 { 599 V4L2_JBTL_LOGD("Failed to set mute mode\n"); 600 return FM_FAILED; 601 } 602 603 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_MUTE_MODE,status); 604 V4L2_JBTL_LOGD("nativeJFmRx_setMuteMode(): Exit"); 605 return FM_PENDING; 606 607 608 } 609 610 611 static int nativeJFmRx_GetMuteMode(JNIEnv *env, jobject obj,jlong jContextValue) 612 { 613 struct v4l2_control vctrl; 614 int status; 615 V4L2_JBTL_LOGD("nativeJFmRx_getMuteMode(): Entered"); 616 vctrl.id = V4L2_CID_AUDIO_MUTE; 617 status = ioctl(radio_fd,VIDIOC_G_CTRL,&vctrl); 618 if(status < 0) 619 { 620 V4L2_JBTL_LOGD("Failed to get mute mode\n"); 621 return FM_FAILED; 622 } 623 624 V4L2_JBTL_LOGD("%d\n",vctrl.value); 625 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_MUTE_MODE,vctrl.value); 626 627 V4L2_JBTL_LOGD("nativeJFmRx_getMuteMode(): Exit"); 628 return FM_PENDING; 629 } 630 631 632 static int nativeJFmRx_SetRssiThreshold(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmRssi) 633 { 634 635 int status; 636 char rssi_lvl[10]; 637 int fd, res; 638 639 V4L2_JBTL_LOGD("nativeJFmRx_setRssiThreshold(): Entered"); 640 641 sprintf(rssi_lvl,"%d",jFmRssi); 642 643 V4L2_JBTL_LOGD("nativeJFmRx_setRssiThreshold(): val = %s", rssi_lvl); 644 ; 645 fd = open(FM_RSSI_LVL_SYSFS_ENTRY, O_RDWR); 646 if (fd < 0) { 647 V4L2_JBTL_LOGD("Can't open %s", FM_RSSI_LVL_SYSFS_ENTRY); 648 return FM_FAILED; 649 } 650 651 res = write(fd, &rssi_lvl, sizeof(char)); 652 if(res <= 0){ 653 V4L2_JBTL_LOGD("Failed to set FM RSSI level\n"); 654 return FM_FAILED; 655 } 656 657 V4L2_JBTL_LOGD("Setting rssi to %d\n",jFmRssi); 658 659 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RSSI_THRESHOLD,status); 660 V4L2_JBTL_LOGD("nativeJFmRx_setRssiThreshold(): Exit"); 661 662 return FM_PENDING; 663 } 664 665 static int nativeJFmRx_GetRssiThreshold(JNIEnv *env, jobject obj,jlong jContextValue) 666 { 667 668 short rssi_threshold; 669 int status; 670 V4L2_JBTL_LOGD("nativeJFmRx_getRssiThreshold(): Entered"); 671 672 status = 0; 673 674 V4L2_JBTL_LOGD("RSSI threshold set to %d\n",rssi_threshold); 675 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RSSI_THRESHOLD,rssi_threshold); 676 V4L2_JBTL_LOGD("nativeJFmRx_getRssiThreshold(): Exit"); 677 return FM_PENDING; 678 } 679 680 static int nativeJFmRx_GetRssi(JNIEnv *env, jobject obj,jlong jContextValue) 681 { 682 int status; 683 short curr_rssi_lvl; 684 685 V4L2_JBTL_LOGD("nativeJFmRx_getRssi(): Entered"); 686 687 status = 0; 688 689 V4L2_JBTL_LOGD("RSSI level is %d\n",curr_rssi_lvl); 690 691 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RSSI,curr_rssi_lvl); 692 V4L2_JBTL_LOGD("nativeJFmRx_getRssi(): Exit"); 693 return FM_PENDING;; 694 695 } 696 697 static int nativeJFmRx_SetVolume(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmVolume) 698 { 699 struct v4l2_control vctrl; 700 int status; 701 702 V4L2_JBTL_LOGD("nativeJFmRx_SetVolume(): Entered"); 703 704 vctrl.id = V4L2_CID_AUDIO_VOLUME; 705 vctrl.value = jFmVolume; 706 707 status = ioctl(radio_fd,VIDIOC_S_CTRL,&vctrl); 708 if(status < 0) 709 { 710 V4L2_JBTL_LOGD("nativeJFmRx_SetVolume():Failed to set volume\n"); 711 return status; 712 } 713 V4L2_JBTL_LOGD("nativeJFmRx_SetVolume():Setting volume to %d \n",jFmVolume); 714 715 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_VOLUME,status); 716 717 V4L2_JBTL_LOGD("nativeJFmRx_SetVolume(): Exit"); 718 return FM_PENDING; 719 720 721 } 722 723 static int nativeJFmRx_GetVolume(JNIEnv *env, jobject obj,jlong jContextValue) 724 { 725 struct v4l2_control vctrl; 726 int status; 727 728 V4L2_JBTL_LOGD("nativeJFmRx_getVolume(): Entered"); 729 730 731 vctrl.id = V4L2_CID_AUDIO_VOLUME; 732 status = ioctl(radio_fd,VIDIOC_G_CTRL,&vctrl); 733 if(status < 0) 734 { 735 V4L2_JBTL_LOGD("Failed to get volume\n"); 736 return status; 737 } 738 739 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_VOLUME,vctrl.value); 740 V4L2_JBTL_LOGD("nativeJFmRx_getVolume(): Exit"); 741 return FM_PENDING; 742 } 743 744 static int nativeJFmRx_SetChannelSpacing(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmChannelSpacing) 745 { 746 747 int status = 0; 748 ALOGD("nativeJFmRx_SetChannelSpacing(): Entered"); 749 750 chanl_spacing = jFmChannelSpacing * 50000; 751 752 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_CHANNEL_SPACING,status); 753 754 ALOGD("nativeJFmRx_SetChannelSpacing(): Exit"); 755 return FM_PENDING; 756 757 } 758 759 static int nativeJFmRx_GetChannelSpacing(JNIEnv *env, jobject obj,jlong jContextValue) 760 { 761 762 int status =0; 763 ALOGD("nativeJFmRx_GetChannelSpacing(): Entered"); 764 765 ALOGD("nativeJFmRx_GetChannelSpacing(): Exit"); 766 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_CHANNEL_SPACING,status); 767 return FM_PENDING; 768 } 769 770 static jint nativeJFmRx_SetDeEmphasisFilter(JNIEnv *env, jobject obj,jlong jContextValue,jint jFmEmphasisFilter) 771 { 772 773 int status; 774 V4L2_JBTL_LOGD("nativeJFmRx_SetDeEmphasisFilter(): Entered"); 775 776 V4L2_JBTL_LOGD("1. nativeJFmRx_EnableRDS\n"); 777 status = 0; 778 779 V4L2_JBTL_LOGD("Set to De-emphasis %d mode\n",jFmEmphasisFilter); 780 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_DEEMPHASIS_FILTER,status); 781 V4L2_JBTL_LOGD("nativeJFmRx_SetDeEmphasisFilter(): Exit"); 782 V4L2_JBTL_LOGD("2. nativeJFmRx_EnableRDS\n"); 783 return FM_PENDING; 784 } 785 786 787 static int nativeJFmRx_GetDeEmphasisFilter(JNIEnv *env, jobject obj,jlong jContextValue) 788 { 789 790 int status; 791 unsigned char mode; 792 793 V4L2_JBTL_LOGD("nativeJFmRx_GetDeEmphasisFilter(): Entered"); 794 795 V4L2_JBTL_LOGD("1. nativeJFmRx_EnableRDS\n"); 796 mode = 0; 797 798 V4L2_JBTL_LOGD("De-emphasis filter %d\n",mode); 799 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_DEEMPHASIS_FILTER,mode); 800 801 V4L2_JBTL_LOGD("nativeJFmRx_GetDeEmphasisFilter(): Exit"); 802 V4L2_JBTL_LOGD("2. nativeJFmRx_EnableRDS\n"); 803 return FM_PENDING; 804 } 805 806 807 808 static int nativeJFmRx_Seek(JNIEnv *env, jobject obj,jlong jContextValue,jint jdirection) 809 { 810 811 struct ti_v4l2_hw_freq_seek frq_seek; 812 struct v4l2_frequency vf; 813 struct v4l2_tuner vt; 814 int status, div; 815 816 V4L2_JBTL_LOGD("nativeJFmRx_Seek(): Entered"); 817 V4L2_JBTL_LOGD("Seeking %s.. and channel spacing is %d\n",jdirection?"up":"down", chanl_spacing); 818 frq_seek.seek_upward = jdirection; 819 frq_seek.type = (v4l2_tuner_type)1; 820 frq_seek.spacing = chanl_spacing; 821 frq_seek.wrap_around = 0; 822 823 errno = 0; 824 status = ioctl(radio_fd,VIDIOC_S_HW_FREQ_SEEK,&frq_seek); 825 if(errno == EAGAIN) 826 { 827 V4L2_JBTL_LOGD("Band limit reached\n"); 828 } 829 else if(status <0) 830 { 831 V4L2_JBTL_LOGD("Seek operation failed\n"); 832 return status; 833 } 834 835 V4L2_JBTL_LOGD("nativeJFmRx_tune(): Entered"); 836 837 vt.index = 0; 838 status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); 839 if(status < 0) 840 { 841 V4L2_JBTL_LOGD("Failed to get tuner capabilities\n"); 842 return FM_FAILED; 843 } 844 845 div = (vt.capability & V4L2_TUNER_CAP_LOW) ? 1000 : 1; 846 847 status = ioctl(radio_fd, VIDIOC_G_FREQUENCY,&vf); 848 if(status < 0) 849 { 850 V4L2_JBTL_LOGD("Failed to read current frequency\n"); 851 return status; 852 } 853 854 V4L2_JBTL_LOGD("Tuned to frequency %3.2f MHz \n",vf.frequency / (16.0 * div)); 855 856 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SEEK,vf.frequency * 1000 / (16 * div)); 857 858 V4L2_JBTL_LOGD("nativeJFmRx_Seek(): Exit"); 859 return FM_PENDING; 860 861 } 862 863 864 static int nativeJFmRx_StopSeek(JNIEnv *env, jobject obj,jlong jContextValue) 865 { 866 int status =0; 867 V4L2_JBTL_LOGD("nativeJFmRx_StopSeek(): Entered"); 868 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_STOP_SEEK,status); 869 V4L2_JBTL_LOGD("nativeJFmRx_StopSeek(): Exit"); 870 return FM_PENDING; 871 } 872 873 static int nativeJFmRx_EnableRDS(JNIEnv *env, jobject obj,jlong jContextValue) 874 { 875 876 int status; 877 unsigned char rds_mode = FM_RDS_ENABLE; 878 struct v4l2_tuner vt; 879 880 V4L2_JBTL_LOGD("nativeJFmRx_enableRDS(): Entered"); 881 882 V4L2_JBTL_LOGD("1. nativeJFmRx_EnableRDS\n"); 883 vt.index = 0; 884 status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); 885 if(status < 0) 886 { 887 V4L2_JBTL_LOGD("Failed to get tuner attributes\n"); 888 return status; 889 } 890 891 V4L2_JBTL_LOGD("2. nativeJFmRx_EnableRDS\n"); 892 893 if ((vt.rxsubchans & V4L2_TUNER_SUB_RDS) != 1) 894 vt.rxsubchans |= V4L2_TUNER_SUB_RDS; 895 896 status = ioctl(radio_fd, VIDIOC_S_TUNER, &vt); 897 if(status < 0) 898 { 899 V4L2_JBTL_LOGD("Failed to set RDS on/off status\n"); 900 return status; 901 } 902 903 V4L2_JBTL_LOGD("3. nativeJFmRx_EnableRDS\n"); 904 if(isThreadCreated == false) 905 { 906 907 V4L2_JBTL_LOGD(" nativeJFmRx_EnableRDS: creating thread !!! \n"); 908 g_stopCommListener = false; 909 /* Create rds receive thread once */ 910 status = pthread_create(&p_threadHandle, /* Thread Handle. */ 911 NULL, /* Default Atributes. */ 912 entryFunctionForRdsThread, /* Entry Function. */ 913 (void *)radio_fd); /* Parameters. */ 914 if (status < 0) 915 { 916 V4L2_JBTL_LOGD(" nativeJFmRx_EnableRDS: Thread Creation FAILED !!! \n"); 917 return FM_ERR_THREAD_CREATION_FAILED; 918 } 919 920 isThreadCreated = true; 921 } 922 else 923 V4L2_JBTL_LOGD("RDS thread already created\n"); 924 925 V4L2_JBTL_LOGD("4. nativeJFmRx_EnableRDS\n"); 926 V4L2_JBTL_LOGD("RDS %d\n",rds_mode); 927 928 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_ENABLE_RDS,status); 929 V4L2_JBTL_LOGD("nativeJFmRx_enableRDS(): Exit"); 930 return FM_PENDING; 931 } 932 933 static int nativeJFmRx_DisableRDS(JNIEnv *env, jobject obj,jlong jContextValue) 934 { 935 936 int status; 937 unsigned char rds_mode = FM_RDS_DISABLE; 938 struct v4l2_tuner vt; 939 940 V4L2_JBTL_LOGD("1. nativeJFmRx_DisableRDS\n"); 941 vt.index = 0; 942 status = ioctl(radio_fd, VIDIOC_G_TUNER, &vt); 943 if(status < 0) 944 { 945 V4L2_JBTL_LOGD("Failed to get tuner attributes\n"); 946 return status; 947 } 948 949 if(vt.rxsubchans & V4L2_TUNER_SUB_RDS) 950 vt.rxsubchans &= ~V4L2_TUNER_SUB_RDS; 951 952 V4L2_JBTL_LOGD("2. nativeJFmRx_DisableRDS and vt.rxsubchans = %d\n", vt.rxsubchans); 953 954 status = ioctl(radio_fd, VIDIOC_S_TUNER, &vt); 955 if(status < 0) 956 { 957 V4L2_JBTL_LOGD("Failed to set RDS on/off status\n"); 958 return status; 959 } 960 961 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_DISABLE_RDS,status); 962 963 V4L2_JBTL_LOGD("nativeJFmRx_DisableRDS(): Exit"); 964 return FM_PENDING; 965 } 966 967 static int nativeJFmRx_EnableAudioRouting(JNIEnv *env, jobject obj,jlong jContextValue) 968 { 969 int status = 0 ; 970 V4L2_JBTL_LOGD("nativeJFmRx_enableAudioRouting(): Entered"); 971 972 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_ENABLE_AUDIO,status); 973 974 V4L2_JBTL_LOGD("nativeJFmRx_enableAudioRouting(): Exit"); 975 return FM_PENDING; 976 } 977 978 static int nativeJFmRx_DisableAudioRouting(JNIEnv *env, jobject obj,jlong jContextValue) 979 { 980 int status = 0 ; 981 V4L2_JBTL_LOGD("nativeJFmRx_disableAudioRouting(): Entered"); 982 983 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_ENABLE_AUDIO,status); 984 985 V4L2_JBTL_LOGD("nativeJFmRx_disableAudioRouting(): Exit"); 986 return FM_PENDING; 987 } 988 989 static int nativeJFmRx_SetRdsAfSwitchMode(JNIEnv *env, jobject obj,jlong jContextValue,jint jRdsAfSwitchMode) 990 { 991 992 int status; 993 char af_switch; 994 int fd, res; 995 996 V4L2_JBTL_LOGD("nativeJFmRx_setRdsAfSwitchMode(): Entered"); 997 998 switch(jRdsAfSwitchMode) { 999 case 1: 1000 af_switch = '1'; 1001 break; 1002 case 0: 1003 default: 1004 af_switch = '0'; 1005 break; 1006 } 1007 1008 fd = open(FM_RDS_AF_SYSFS_ENTRY, O_RDWR); 1009 if (fd < 0) { 1010 V4L2_JBTL_LOGD("Can't open %s", FM_RDS_AF_SYSFS_ENTRY); 1011 return FM_FAILED; 1012 } 1013 1014 res = write(fd, &af_switch, sizeof(char)); 1015 if(res <= 0){ 1016 V4L2_JBTL_LOGD("Failed to set FM AF Switch\n"); 1017 return FM_FAILED; 1018 } 1019 1020 1021 V4L2_JBTL_LOGD("AF Switch %d ",jRdsAfSwitchMode); 1022 1023 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RDS_AF_SWITCH_MODE,status); 1024 V4L2_JBTL_LOGD("nativeJFmRx_setRdsAfSwitchMode(): Exit"); 1025 return FM_PENDING; 1026 1027 } 1028 1029 static int nativeJFmRx_GetRdsAfSwitchMode(JNIEnv *env, jobject obj,jlong jContextValue) 1030 { 1031 1032 int status; 1033 unsigned char af_mode; 1034 1035 1036 V4L2_JBTL_LOGD("nativeJFmRx_getRdsAfSwitchMode(): Entered"); 1037 1038 status = 0; 1039 1040 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RDS_AF_SWITCH_MODE,af_mode); 1041 V4L2_JBTL_LOGD("nativeJFmRx_getRdsAfSwitchMode(): Exit"); 1042 return FM_PENDING; 1043 } 1044 1045 static int nativeJFmRx_ChangeAudioTarget (JNIEnv *env, jobject obj,jlong jContextValue, jint jFmRxAudioTargetMask, jint digitalConfig) 1046 { 1047 1048 V4L2_JBTL_LOGD("nativeJFmRx_ChangeAudioTarget(): Entered"); 1049 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_CHANGE_AUDIO_TARGET,status); 1050 V4L2_JBTL_LOGD("nativeJFmRx_ChangeAudioTarget(): Exit"); 1051 return FM_PENDING; 1052 1053 } 1054 1055 1056 static int nativeJFmRx_ChangeDigitalTargetConfiguration(JNIEnv *env, jobject obj,jlong jContextValue,jint digitalConfig) 1057 { 1058 1059 V4L2_JBTL_LOGD("nativeJFmRx_ChangeDigitalTargetConfiguration(): Entered"); 1060 1061 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION,status); 1062 1063 V4L2_JBTL_LOGD("nativeJFmRx_ChangeDigitalTargetConfiguration(): Exit"); 1064 return FM_PENDING; 1065 1066 } 1067 1068 1069 static int nativeJFmRx_SetRfDependentMuteMode(JNIEnv *env, jobject obj,jlong jContextValue, jint rf_mute) 1070 { 1071 1072 int status; 1073 V4L2_JBTL_LOGD("nativeJFmRx_SetRfDependentMuteMode(): Entered"); 1074 1075 status = 0; 1076 1077 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RF_DEPENDENT_MUTE_MODE,status); 1078 V4L2_JBTL_LOGD("nativeJFmRx_SetRfDependentMuteMode(): Exit"); 1079 return FM_PENDING; 1080 1081 1082 1083 } 1084 1085 1086 static int nativeJFmRx_GetRfDependentMute(JNIEnv *env, jobject obj,jlong jContextValue) 1087 { 1088 1089 int status; 1090 unsigned char rf_mute; 1091 V4L2_JBTL_LOGD(" nativeJFmRx_GetRfDependentMute(): Entered"); 1092 1093 status = 0; 1094 1095 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RF_DEPENDENT_MUTE_MODE,rf_mute); 1096 V4L2_JBTL_LOGD(" nativeJFmRx_GetRfDependentMute(): Exit"); 1097 return FM_PENDING; 1098 1099 } 1100 1101 1102 static int nativeJFmRx_SetRdsSystem(JNIEnv *env, jobject obj,jlong jContextValue, jint rdsSystem) 1103 { 1104 int status; 1105 1106 V4L2_JBTL_LOGD(" nativeJFmRx_SetRdsSystem(): Entered"); 1107 1108 V4L2_JBTL_LOGD("entered to ELSE\n"); 1109 status = 0; 1110 1111 V4L2_JBTL_LOGD("Set to %d\n",rdsSystem); 1112 nativeJFmRx_Callback(jContext,status,FM_RX_CMD_SET_RDS_SYSTEM,status); 1113 V4L2_JBTL_LOGD(" nativeJFmRx_SetRdsSystem(): Exit"); 1114 return FM_PENDING; 1115 1116 1117 1118 } 1119 1120 1121 static int nativeJFmRx_GetRdsSystem(JNIEnv *env, jobject obj,jlong jContextValue) 1122 { 1123 1124 int status; 1125 unsigned char mode; 1126 1127 V4L2_JBTL_LOGD("nativeJFmRx_GetRdsSystem(): Entered"); 1128 1129 status = 0; 1130 1131 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RDS_SYSTEM,mode); 1132 V4L2_JBTL_LOGD(" nativeJFmRx_GetRdsSystem(): Exit"); 1133 return FM_PENDING; 1134 1135 } 1136 1137 1138 static int nativeJFmRx_SetRdsGroupMask(JNIEnv *env, jobject obj,jlong jContextValue, jlong groupMask) 1139 { 1140 int status =0; 1141 V4L2_JBTL_LOGD("nativeJFmRx_SetRdsGroupMask(): Entered"); 1142 1143 1144 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_SET_RDS_GROUP_MASK,status); 1145 V4L2_JBTL_LOGD(" nativeJFmRx_SetRdsGroupMask(): Exit"); 1146 return FM_PENDING; 1147 1148 } 1149 1150 static int nativeJFmRx_GetRdsGroupMask(JNIEnv *env, jobject obj,jlong jContextValue) 1151 { 1152 int status =0; 1153 V4L2_JBTL_LOGD("nativeJFmRx_GetRdsGroupMask(): Entered"); 1154 1155 1156 nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_RDS_GROUP_MASK,status); 1157 V4L2_JBTL_LOGD(" nativeJFmRx_GetRdsGroupMask(): Exit"); 1158 return FM_PENDING; 1159 1160 } 1161 1162 static int nativeJFmRx_CompleteScan(JNIEnv *env, jobject obj, jlong jContextValue) 1163 { 1164 1165 int status =0; 1166 ALOGD("nativeJFmRx_CompleteScan(): Entered"); 1167 1168 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_COMPLETE_SCAN,status); 1169 ALOGD("nativeJFmRx_CompleteScan(): Exit"); 1170 return FM_PENDING; 1171 } 1172 1173 static int nativeJFmRx_GetCompleteScanProgress(JNIEnv *env, jobject obj, jlong jContextValue) 1174 { 1175 int status =0; 1176 ALOGD("nativeJFmRx_GetCompleteScanProgress(): Entered"); 1177 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_COMPLETE_SCAN_PROGRESS,status); 1178 1179 ALOGD("nativeJFmRx_GetCompleteScanProgress(): Exit"); 1180 return FM_PENDING; 1181 } 1182 1183 static int nativeJFmRx_StopCompleteScan(JNIEnv *env, jobject obj, jlong jContextValue) 1184 { 1185 1186 ALOGD("nativeJFmRx_StopCompleteScan(): Entered"); 1187 1188 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_STOP_COMPLETE_SCAN,status); 1189 ALOGD("nativeJFmRx_StopCompleteScan(): Exit"); 1190 return FM_PENDING; 1191 } 1192 1193 static int nativeJFmRx_IsValidChannel(JNIEnv *env, jobject obj, jlong jContextValue) 1194 { 1195 1196 1197 ALOGD("nativeJFmRx_IsValidChannel(): Entered"); 1198 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_IS_CHANNEL_VALID ,status); 1199 ALOGD("nativeJFmRx_IsValidChannel(): Exit"); 1200 return FM_PENDING; 1201 } 1202 1203 1204 static int nativeJFmRx_GetFwVersion(JNIEnv *env, jobject obj, jlong jContextValue) 1205 { 1206 1207 ALOGD("nativeJFmRx_GetFwVersion(): Entered"); 1208 //nativeJFmRx_Callback(jContext,status, FM_RX_CMD_GET_FW_VERSION,status); 1209 ALOGD("nativeJFmRx_GetFwVersion(): Exit"); 1210 return FM_PENDING; 1211 } 1212 1213 1214 //################################################################################ 1215 1216 // SIGNALS 1217 1218 //############################################################################### 1219 1220 extern "C" 1221 { 1222 1223 void nativeJFmRx_RadioText_Callback(int status, bool resetDisplay, 1224 unsigned char * msg, int len, int startIndex, 1225 int repertoire) 1226 { 1227 ALOGE("nativeJFmRx_RadioText_Callback: Entering"); 1228 1229 ALOGE("nativeJFmRx_RadioText_Callback: msg %s",msg); 1230 JNIEnv* env = NULL; 1231 bool attachedThread = false; 1232 int jRet ; 1233 jbyteArray jRadioTxtMsg = NULL; 1234 1235 /* check whether the current thread is attached to a virtual machine instance, 1236 if no only then try to attach to the current thread. */ 1237 jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); 1238 1239 if(jRet < 0) 1240 { 1241 ALOGE("failed to get JNI env,assuming native thread"); 1242 jRet = g_jVM->AttachCurrentThread((&env), NULL); 1243 1244 if(jRet != JNI_OK) 1245 { 1246 ALOGE("failed to atatch to current thread %d",jRet); 1247 return ; 1248 } 1249 1250 attachedThread = true; 1251 } 1252 1253 1254 1255 1256 if(env == NULL) { 1257 ALOGI("%s: Entered, env is null", __func__); 1258 } else { 1259 ALOGD("%s: jEnv %p", __func__, (void *)env); 1260 } 1261 1262 1263 V4L2_JBTL_LOGD("nativeJFmRx_Callback():EVENT --------------->FM_RX_EVENT_RADIO_TEXT"); 1264 jRadioTxtMsg = env->NewByteArray(len); 1265 if (jRadioTxtMsg == NULL) { 1266 ALOGE("%s: Failed converting elements", __func__); 1267 goto CLEANUP; 1268 } 1269 1270 env->SetByteArrayRegion(jRadioTxtMsg, 1271 0, 1272 len, 1273 (jbyte*)msg); 1274 1275 if (env->ExceptionOccurred()) { 1276 ALOGE("%s: Calling nativeCb_fmRxRadioText failed", 1277 __func__); 1278 goto CLEANUP; 1279 } 1280 1281 env->CallStaticVoidMethod(_sJClass, 1282 _sMethodId_nativeCb_fmRxRadioText,(jlong)jContext, 1283 (jint)status, 1284 (jboolean)resetDisplay, 1285 jRadioTxtMsg, 1286 (jint)len, 1287 (jint)startIndex, 1288 (jint)repertoire); 1289 1290 if (env->ExceptionOccurred()) { 1291 ALOGE("nativeJFmRx_RadioText_Callback: ExceptionOccurred"); 1292 goto CLEANUP; 1293 } 1294 1295 if(jRadioTxtMsg!= NULL) 1296 env->DeleteLocalRef(jRadioTxtMsg); 1297 1298 if(attachedThread == true) 1299 g_jVM->DetachCurrentThread(); 1300 1301 return ; 1302 1303 CLEANUP: 1304 ALOGE("nativeJFmRx_RadioText_Callback: Exiting due to failure"); 1305 1306 if(jRadioTxtMsg!= NULL) 1307 env->DeleteLocalRef(jRadioTxtMsg); 1308 if (env->ExceptionOccurred()) { 1309 env->ExceptionDescribe(); 1310 env->ExceptionClear(); 1311 } 1312 1313 if(attachedThread == true) 1314 g_jVM->DetachCurrentThread(); 1315 return ; 1316 } 1317 1318 1319 1320 1321 1322 void nativeJFmRx_PS_Callback(long context,int status, int freq, 1323 int len,unsigned char * name, 1324 int repertoire) 1325 1326 { 1327 ALOGE("nativeJFmRx_PS_Callback: Exiting due to failure"); 1328 JNIEnv* env = NULL; 1329 bool attachedThread = false; 1330 int jRet ; 1331 jbyteArray jNameString = NULL; 1332 int frequency =0; 1333 1334 /* check whether the current thread is attached to a virtual machine instance, 1335 if no only then try to attach to the current thread. */ 1336 jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); 1337 1338 if(jRet < 0) 1339 { 1340 ALOGE("failed to get JNI env,assuming native thread"); 1341 jRet = g_jVM->AttachCurrentThread((&env), NULL); 1342 1343 if(jRet != JNI_OK) 1344 { 1345 ALOGE("failed to atatch to current thread %d",jRet); 1346 return ; 1347 } 1348 1349 attachedThread = true; 1350 } 1351 1352 1353 1354 1355 if(env == NULL) { 1356 ALOGI("%s: Entered, env is null", __func__); 1357 } else { 1358 ALOGD("%s: jEnv %p", __func__, (void *)env); 1359 } 1360 1361 V4L2_JBTL_LOGD("nativeJFmRx_PS_Callback():EVENT --------------->FM_RX_EVENT_PS_CHANGED len %d",len); 1362 1363 1364 jNameString = env->NewByteArray(len); 1365 1366 if (jNameString == NULL) 1367 { 1368 V4L2_JBTL_LOGD("nativeJFmRx_PS_Callback: Failed converting elements"); 1369 goto CLEANUP; 1370 } 1371 1372 env->SetByteArrayRegion(jNameString,0,len,(jbyte*)name); 1373 1374 if (env->ExceptionOccurred()) { 1375 V4L2_JBTL_LOGD("nativeJFmRx_PS_Callback: Calling Java nativeCb_fmRxRadioText failed"); 1376 goto CLEANUP; 1377 } 1378 1379 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxPsChanged,(jlong)context, 1380 (jint)status, 1381 (jint)frequency, 1382 jNameString, 1383 (jint)repertoire); 1384 1385 1386 if (env->ExceptionOccurred()) { 1387 ALOGE("nativeJFmRx_PS_Callback: ExceptionOccurred"); 1388 goto CLEANUP; 1389 } 1390 1391 if(jNameString!= NULL) 1392 env->DeleteLocalRef(jNameString); 1393 1394 if(attachedThread == true) 1395 g_jVM->DetachCurrentThread(); 1396 1397 return ; 1398 1399 CLEANUP: 1400 ALOGE("nativeJFmRx_PS_Callback: Exiting due to failure"); 1401 1402 if(jNameString!= NULL) 1403 env->DeleteLocalRef(jNameString); 1404 if (env->ExceptionOccurred()) { 1405 env->ExceptionDescribe(); 1406 env->ExceptionClear(); 1407 } 1408 1409 if(attachedThread == true) 1410 g_jVM->DetachCurrentThread(); 1411 return ; 1412 } 1413 1414 1415 void nativeJFmRx_Callback(long context, int status, 1416 int command, long value) 1417 { 1418 1419 V4L2_JBTL_LOGI("nativeJFmRx_Callback: Entered, "); 1420 1421 JNIEnv* env = NULL; 1422 bool attachedThread = false; 1423 int jRet ; 1424 1425 /* check whether the current thread is attached to a virtual machine instance, 1426 if no only then try to attach to the current thread. */ 1427 1428 jRet = g_jVM->GetEnv((void **)&env,JNI_VERSION_1_4); 1429 1430 if(jRet < 0) 1431 { 1432 V4L2_JBTL_LOGI("failed to get JNI env,assuming native thread"); 1433 jRet = g_jVM->AttachCurrentThread((&env), NULL); 1434 1435 if(jRet != JNI_OK) 1436 { 1437 V4L2_JBTL_LOGI("failed to atatch to current thread %d",jRet); 1438 return ; 1439 } 1440 1441 attachedThread = true; 1442 } 1443 1444 if(env == NULL) 1445 { 1446 V4L2_JBTL_LOGD("nativeJFmRx_Callback: Entered, env is null"); 1447 } 1448 1449 1450 switch (command) 1451 { 1452 1453 case FM_RX_CMD_ENABLE: 1454 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdEnable,(jlong)context, 1455 (jint)status, 1456 (jint)command, 1457 (jlong)value); 1458 break; 1459 1460 case FM_RX_CMD_DISABLE: 1461 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdDisable,(jlong)context, 1462 (jint)status, 1463 (jint)command, 1464 (jlong)value); 1465 break; 1466 1467 case FM_RX_CMD_SET_BAND: 1468 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetBand,(jlong)context, 1469 (jint)status, 1470 (jint)command, 1471 (jlong)value); 1472 break; 1473 1474 case FM_RX_CMD_GET_BAND: 1475 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetBand,(jlong)context, 1476 (jint)status, 1477 (jint)command, 1478 (jlong)value); 1479 break; 1480 1481 case FM_RX_CMD_SET_MONO_STEREO_MODE: 1482 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetMonoStereoMode,(jlong)context, 1483 (jint)status, 1484 (jint)command, 1485 (jlong)value); 1486 break; 1487 1488 case FM_RX_CMD_GET_MONO_STEREO_MODE: 1489 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetMonoStereoMode,(jlong)context, 1490 (jint)status, 1491 (jint)command, 1492 (jlong)value); 1493 break; 1494 1495 case FM_RX_CMD_SET_MUTE_MODE: 1496 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetMuteMode,(jlong)context, 1497 (jint)status, 1498 (jint)command, 1499 (jlong)value); 1500 break; 1501 1502 case FM_RX_CMD_GET_MUTE_MODE: 1503 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetMuteMode,(jlong)context, 1504 (jint)status, 1505 (jint)command, 1506 (jlong)value); 1507 break; 1508 1509 case FM_RX_CMD_SET_RF_DEPENDENT_MUTE_MODE: 1510 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode,(jlong)context, 1511 (jint)status, 1512 (jint)command, 1513 (jlong)value); 1514 break; 1515 1516 case FM_RX_CMD_GET_RF_DEPENDENT_MUTE_MODE: 1517 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode,(jlong)context, 1518 (jint)status, 1519 (jint)command, 1520 (jlong)value); 1521 break; 1522 1523 case FM_RX_CMD_SET_RSSI_THRESHOLD: 1524 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRssiThreshhold,(jlong)context, 1525 (jint)status, 1526 (jint)command, 1527 (jlong)value); 1528 break; 1529 1530 case FM_RX_CMD_GET_RSSI_THRESHOLD: 1531 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRssiThreshhold,(jlong)context, 1532 (jint)status, 1533 (jint)command, 1534 (jlong)value); 1535 break; 1536 1537 case FM_RX_CMD_SET_DEEMPHASIS_FILTER: 1538 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter,(jlong)context, 1539 (jint)status, 1540 (jint)command, 1541 (jlong)value); 1542 break; 1543 1544 case FM_RX_CMD_GET_DEEMPHASIS_FILTER: 1545 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter,(jlong)context, 1546 (jint)status, 1547 (jint)command, 1548 (jlong)value); 1549 break; 1550 1551 case FM_RX_CMD_SET_VOLUME: 1552 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetVolume,(jlong)context, 1553 (jint)status, 1554 (jint)command, 1555 (jlong)value); 1556 break; 1557 1558 case FM_RX_CMD_GET_VOLUME: 1559 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetVolume,(jlong)context, 1560 (jint)status, 1561 (jint)command, 1562 (jlong)value); 1563 break; 1564 1565 case FM_RX_CMD_TUNE: 1566 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdTune,(jlong)context, 1567 (jint)status, 1568 (jint)command, 1569 (jlong)value); 1570 break; 1571 1572 case FM_RX_CMD_GET_TUNED_FREQUENCY: 1573 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetTunedFrequency,(jlong)context, 1574 (jint)status, 1575 (jint)command, 1576 (jlong)value); 1577 break; 1578 1579 case FM_RX_CMD_SEEK: 1580 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSeek,(jlong)context, 1581 (jint)status, 1582 (jint)command, 1583 (jlong)value); 1584 break; 1585 1586 case FM_RX_CMD_STOP_SEEK: 1587 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdStopSeek,(jlong)context, 1588 (jint)status, 1589 (jint)command, 1590 (jlong)value); 1591 break; 1592 1593 case FM_RX_CMD_GET_RSSI: 1594 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRssi,(jlong)context, 1595 (jint)status, 1596 (jint)command, 1597 (jlong)value); 1598 break; 1599 1600 case FM_RX_CMD_ENABLE_RDS: 1601 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdEnableRds,(jlong)context, 1602 (jint)status, 1603 (jint)command, 1604 (jlong)value); 1605 break; 1606 1607 case FM_RX_CMD_DISABLE_RDS: 1608 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdDisableRds,(jlong)context, 1609 (jint)status, 1610 (jint)command, 1611 (jlong)value); 1612 break; 1613 1614 case FM_RX_CMD_SET_RDS_SYSTEM: 1615 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRdsSystem,(jlong)context, 1616 (jint)status, 1617 (jint)command, 1618 (jlong)value); 1619 break; 1620 1621 case FM_RX_CMD_GET_RDS_SYSTEM: 1622 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRdsSystem,(jlong)context, 1623 (jint)status, 1624 (jint)command, 1625 (jlong)value); 1626 break; 1627 1628 case FM_RX_CMD_SET_RDS_GROUP_MASK: 1629 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRdsGroupMask,(jlong)context, 1630 (jint)status, 1631 (jint)command, 1632 (jlong)value); 1633 break; 1634 1635 case FM_RX_CMD_GET_RDS_GROUP_MASK: 1636 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRdsGroupMask,(jlong)context, 1637 (jint)status, 1638 (jint)command, 1639 (jlong)value); 1640 break; 1641 1642 case FM_RX_CMD_SET_RDS_AF_SWITCH_MODE: 1643 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode,(jlong)context, 1644 (jint)status, 1645 (jint)command, 1646 (jlong)value); 1647 break; 1648 1649 case FM_RX_CMD_GET_RDS_AF_SWITCH_MODE: 1650 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode,(jlong)context, 1651 (jint)status, 1652 (jint)command, 1653 (jlong)value); 1654 break; 1655 1656 case FM_RX_CMD_ENABLE_AUDIO: 1657 V4L2_JBTL_LOGD("nativeJFmRx_Callback: at FM_RX_CMD_ENABLE_AUDIO step 1"); 1658 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdEnableAudio,(jlong)context, 1659 (jint)status, 1660 (jint)command, 1661 (jlong)value); 1662 V4L2_JBTL_LOGD("nativeJFmRx_Callback: at FM_RX_CMD_ENABLE_AUDIO step 2"); 1663 break; 1664 1665 case FM_RX_CMD_DISABLE_AUDIO: 1666 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdDisableAudio, (jlong)context, 1667 (jint)status, 1668 (jint)command, 1669 (jlong)value); 1670 break; 1671 1672 case FM_RX_CMD_CHANGE_AUDIO_TARGET: 1673 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdChangeAudioTarget,(jlong)context, 1674 (jint)status, 1675 (jint)command, 1676 (jlong)value); 1677 break; 1678 1679 case FM_RX_CMD_CHANGE_DIGITAL_AUDIO_CONFIGURATION: 1680 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration,(jlong)context, 1681 (jint)status, 1682 (jint)command, 1683 (jlong)value); 1684 break; 1685 1686 case FM_RX_CMD_SET_CHANNEL_SPACING: 1687 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdSetChannelSpacing,(jlong)context, 1688 (jint)status, 1689 (jint)command, 1690 (jlong)value); 1691 break; 1692 1693 case FM_RX_CMD_GET_CHANNEL_SPACING: 1694 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetChannelSpacing,(jlong)context, 1695 (jint)status, 1696 (jint)command, 1697 (jlong)value); 1698 break; 1699 1700 case FM_RX_CMD_GET_FW_VERSION: 1701 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetFwVersion,(jlong)context, 1702 (jint)status, 1703 (jint)command, 1704 (jlong)value); 1705 break; 1706 1707 case FM_RX_CMD_IS_CHANNEL_VALID: 1708 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdIsValidChannel,(jlong)context, 1709 (jint)status, 1710 (jint)command, 1711 (jlong)value); 1712 break; 1713 1714 case FM_RX_CMD_COMPLETE_SCAN_PROGRESS: 1715 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress,(jlong)context, 1716 (jint)status, 1717 (jint)command, 1718 (jlong)value); 1719 break; 1720 1721 case FM_RX_CMD_STOP_COMPLETE_SCAN: 1722 env->CallStaticVoidMethod(_sJClass,_sMethodId_nativeCb_fmRxCmdStopCompleteScan,(jlong)context, 1723 (jint)status, 1724 (jint)command, 1725 (jlong)value); 1726 break; 1727 1728 default: 1729 V4L2_JBTL_LOGD("nativeJFmRx_Callback:FM_RX_EVENT_CMD_DONE,unhendeld event"); 1730 break; 1731 } 1732 1733 if (env->ExceptionOccurred()) { 1734 V4L2_JBTL_LOGD("nativeJFmRx_Callback: ExceptionOccurred"); 1735 goto EXCEPTION; 1736 } 1737 1738 V4L2_JBTL_LOGD("nativeJFmRx_Callback: Exiting, Calling DetachCurrentThread at the END"); 1739 if(attachedThread == true) 1740 g_jVM->DetachCurrentThread(); 1741 1742 return; 1743 1744 EXCEPTION: 1745 1746 /*Delete Jni Local refrencece */ 1747 V4L2_JBTL_LOGD("nativeJFmRx_Callback: Exiting due to failure"); 1748 if (env->ExceptionOccurred()) { 1749 env->ExceptionDescribe(); 1750 env->ExceptionClear(); 1751 } 1752 if(attachedThread == true) 1753 g_jVM->DetachCurrentThread(); 1754 1755 return; 1756 1757 } 1758 1759 1760 } //extern c 1761 1762 1763 /********************************************************************** 1764 * Callback registration 1765 1766 ***********************************************************************/ 1767 #define VERIFY_METHOD_ID(methodId) \ 1768 if (!_VerifyMethodId(methodId, #methodId)) { \ 1769 V4L2_JBTL_LOGD("Error obtaining method id for %s", #methodId); \ 1770 return; \ 1771 } 1772 1773 static bool _VerifyMethodId(jmethodID methodId, const char *name) 1774 { 1775 bool result = true; 1776 1777 if (methodId == NULL) 1778 { 1779 V4L2_JBTL_LOGD("_VerifyMethodId: Failed getting method id of %s", name); 1780 result = false; 1781 } 1782 1783 return result; 1784 } 1785 1786 1787 1788 void nativeJFmRx_ClassInitNative(JNIEnv* env, jclass clazz){ 1789 V4L2_JBTL_LOGD("nativeJFmRx_ClassInitNative: Entered"); 1790 1791 if (NULL == env) 1792 { 1793 V4L2_JBTL_LOGD("nativeJFmRx_ClassInitNative: NULL == env"); 1794 } 1795 1796 env->GetJavaVM(&g_jVM); 1797 1798 1799 1800 /* Save class information in global reference in order to prevent class unloading */ 1801 _sJClass = (jclass)env->NewGlobalRef(clazz); 1802 1803 1804 V4L2_JBTL_LOGI("nativeJFmRx_ClassInitNative: Obtaining method IDs"); 1805 1806 _sMethodId_nativeCb_fmRxRadioText = env->GetStaticMethodID(clazz, 1807 "nativeCb_fmRxRadioText", 1808 "(JIZ[BIII)V"); 1809 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxRadioText); 1810 1811 1812 _sMethodId_nativeCb_fmRxPsChanged = env->GetStaticMethodID(clazz, 1813 "nativeCb_fmRxPsChanged", 1814 "(JII[BI)V"); 1815 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxPsChanged); 1816 1817 /* Complete parsing of the RDS data has not been implemented yet 1818 Commented the FM RX RDS callbacks functionality start*/ 1819 1820 #if 0 1821 _sMethodId_nativeCb_fmRxRawRDS = env->GetStaticMethodID(clazz, 1822 "nativeCb_fmRxRawRDS", 1823 "(JII[B)V"); 1824 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxRawRDS); 1825 1826 1827 _sMethodId_nativeCb_fmRxPiCodeChanged = env->GetStaticMethodID(clazz, 1828 "nativeCb_fmRxPiCodeChanged", 1829 "(JII)V"); 1830 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxPiCodeChanged); 1831 1832 1833 _sMethodId_nativeCb_fmRxPtyCodeChanged = env->GetStaticMethodID(clazz, 1834 "nativeCb_fmRxPtyCodeChanged", 1835 "(JII)V"); 1836 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxPtyCodeChanged); 1837 1838 1839 1840 1841 _sMethodId_nativeCb_fmRxMonoStereoModeChanged = env->GetStaticMethodID(clazz, 1842 "nativeCb_fmRxMonoStereoModeChanged", 1843 "(JII)V"); 1844 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxMonoStereoModeChanged); 1845 1846 1847 _sMethodId_nativeCb_fmRxAudioPathChanged = env->GetStaticMethodID(clazz, 1848 "nativeCb_fmRxAudioPathChanged", 1849 "(JI)V"); 1850 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAudioPathChanged); 1851 1852 1853 _sMethodId_nativeCb_fmRxAfSwitchFreqFailed = env->GetStaticMethodID(clazz, 1854 "nativeCb_fmRxAfSwitchFreqFailed", 1855 "(JIIII)V"); 1856 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfSwitchFreqFailed); 1857 1858 1859 _sMethodId_nativeCb_fmRxAfSwitchStart = env->GetStaticMethodID(clazz, 1860 "nativeCb_fmRxAfSwitchStart", 1861 "(JIIII)V"); 1862 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfSwitchStart); 1863 1864 1865 _sMethodId_nativeCb_fmRxAfSwitchComplete = env->GetStaticMethodID(clazz, 1866 "nativeCb_fmRxAfSwitchComplete", 1867 "(JIIII)V"); 1868 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfSwitchComplete); 1869 1870 1871 _sMethodId_nativeCb_fmRxAfListChanged = env->GetStaticMethodID(clazz, 1872 "nativeCb_fmRxAfListChanged", 1873 "(JII[BI)V"); 1874 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxAfListChanged); 1875 1876 #endif 1877 /*Commented the FM RX RDS callbacks functionality end*/ 1878 1879 1880 _sMethodId_nativeCb_fmRxCmdEnable = env->GetStaticMethodID(clazz, 1881 "nativeCb_fmRxCmdEnable", 1882 "(JIIJ)V"); 1883 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdEnable); 1884 1885 1886 _sMethodId_nativeCb_fmRxCmdDisable = env->GetStaticMethodID(clazz, 1887 "nativeCb_fmRxCmdDisable", 1888 "(JIIJ)V"); 1889 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDisable); 1890 1891 _sMethodId_nativeCb_fmRxCmdEnableAudio = env->GetStaticMethodID(clazz, 1892 "nativeCb_fmRxCmdEnableAudio", 1893 "(JIIJ)V"); 1894 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdEnableAudio); 1895 1896 1897 1898 _sMethodId_nativeCb_fmRxCmdChangeAudioTarget = env->GetStaticMethodID(clazz, 1899 "nativeCb_fmRxCmdChangeAudioTarget", 1900 "(JIIJ)V"); 1901 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdChangeAudioTarget); 1902 1903 1904 _sMethodId_nativeCb_fmRxCmdSetBand = env->GetStaticMethodID(clazz, 1905 "nativeCb_fmRxCmdSetBand", 1906 "(JIIJ)V"); 1907 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetBand); 1908 1909 _sMethodId_nativeCb_fmRxCmdGetBand = env->GetStaticMethodID(clazz, 1910 "nativeCb_fmRxCmdGetBand", 1911 "(JIIJ)V"); 1912 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetBand); 1913 1914 1915 1916 _sMethodId_nativeCb_fmRxCmdSetMonoStereoMode = env->GetStaticMethodID(clazz, 1917 "nativeCb_fmRxCmdSetMonoStereoMode", 1918 "(JIIJ)V"); 1919 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetMonoStereoMode); 1920 1921 1922 1923 _sMethodId_nativeCb_fmRxCmdGetMonoStereoMode = env->GetStaticMethodID(clazz, 1924 "nativeCb_fmRxCmdGetMonoStereoMode", 1925 "(JIIJ)V"); 1926 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetMonoStereoMode); 1927 1928 1929 1930 _sMethodId_nativeCb_fmRxCmdGetMuteMode = env->GetStaticMethodID(clazz, 1931 "nativeCb_fmRxCmdGetMuteMode", 1932 "(JIIJ)V"); 1933 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetMuteMode); 1934 1935 1936 1937 _sMethodId_nativeCb_fmRxCmdSetMuteMode = env->GetStaticMethodID(clazz, 1938 "nativeCb_fmRxCmdSetMuteMode", 1939 "(JIIJ)V"); 1940 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetMuteMode); 1941 1942 1943 1944 _sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode = env->GetStaticMethodID(clazz, 1945 "nativeCb_fmRxCmdSetRfDependentMuteMode", 1946 "(JIIJ)V"); 1947 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRfDependentMuteMode); 1948 1949 1950 1951 _sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode = env->GetStaticMethodID(clazz, 1952 "nativeCb_fmRxCmdGetRfDependentMuteMode", 1953 "(JIIJ)V"); 1954 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRfDependentMuteMode); 1955 1956 1957 1958 _sMethodId_nativeCb_fmRxCmdSetRssiThreshhold = env->GetStaticMethodID(clazz, 1959 "nativeCb_fmRxCmdSetRssiThreshhold", 1960 "(JIIJ)V"); 1961 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRssiThreshhold); 1962 1963 1964 1965 _sMethodId_nativeCb_fmRxCmdGetRssiThreshhold = env->GetStaticMethodID(clazz, 1966 "nativeCb_fmRxCmdGetRssiThreshhold", 1967 "(JIIJ)V"); 1968 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRssiThreshhold); 1969 1970 1971 1972 _sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter = env->GetStaticMethodID(clazz, 1973 "nativeCb_fmRxCmdSetDeemphasisFilter", 1974 "(JIIJ)V"); 1975 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetDeemphasisFilter); 1976 1977 1978 _sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter = env->GetStaticMethodID(clazz, 1979 "nativeCb_fmRxCmdGetDeemphasisFilter", 1980 "(JIIJ)V"); 1981 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetDeemphasisFilter); 1982 1983 1984 1985 _sMethodId_nativeCb_fmRxCmdSetVolume = env->GetStaticMethodID(clazz, 1986 "nativeCb_fmRxCmdSetVolume", 1987 "(JIIJ)V"); 1988 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetVolume); 1989 1990 1991 1992 _sMethodId_nativeCb_fmRxCmdGetVolume = env->GetStaticMethodID(clazz, 1993 "nativeCb_fmRxCmdGetVolume", 1994 "(JIIJ)V"); 1995 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetVolume); 1996 1997 _sMethodId_nativeCb_fmRxCmdSetChannelSpacing = env->GetStaticMethodID(clazz, 1998 "nativeCb_fmRxCmdSetChannelSpacing", 1999 "(JIIJ)V"); 2000 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetChannelSpacing); 2001 2002 2003 2004 _sMethodId_nativeCb_fmRxCmdGetChannelSpacing = env->GetStaticMethodID(clazz, 2005 "nativeCb_fmRxCmdGetChannelSpacing", 2006 "(JIIJ)V"); 2007 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetChannelSpacing); 2008 2009 2010 2011 _sMethodId_nativeCb_fmRxCmdTune = env->GetStaticMethodID(clazz, 2012 "nativeCb_fmRxCmdTune", 2013 "(JIIJ)V"); 2014 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdTune); 2015 2016 2017 _sMethodId_nativeCb_fmRxCmdGetTunedFrequency = env->GetStaticMethodID(clazz, 2018 "nativeCb_fmRxCmdGetTunedFrequency", 2019 "(JIIJ)V"); 2020 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetTunedFrequency); 2021 2022 2023 _sMethodId_nativeCb_fmRxCmdSeek = env->GetStaticMethodID(clazz, 2024 "nativeCb_fmRxCmdSeek", 2025 "(JIIJ)V"); 2026 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSeek); 2027 2028 2029 2030 _sMethodId_nativeCb_fmRxCmdStopSeek = env->GetStaticMethodID(clazz, 2031 "nativeCb_fmRxCmdStopSeek", 2032 "(JIIJ)V"); 2033 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdStopSeek); 2034 2035 2036 _sMethodId_nativeCb_fmRxCmdGetRssi = env->GetStaticMethodID(clazz, 2037 "nativeCb_fmRxCmdGetRssi", 2038 "(JIIJ)V"); 2039 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRssi); 2040 2041 2042 _sMethodId_nativeCb_fmRxCmdEnableRds = env->GetStaticMethodID(clazz, 2043 "nativeCb_fmRxCmdEnableRds", 2044 "(JIIJ)V"); 2045 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdEnableRds); 2046 2047 2048 _sMethodId_nativeCb_fmRxCmdDisableRds = env->GetStaticMethodID(clazz, 2049 "nativeCb_fmRxCmdDisableRds", 2050 "(JIIJ)V"); 2051 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDisableRds); 2052 2053 2054 _sMethodId_nativeCb_fmRxCmdGetRdsSystem = env->GetStaticMethodID(clazz, 2055 "nativeCb_fmRxCmdGetRdsSystem", 2056 "(JIIJ)V"); 2057 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRdsSystem); 2058 2059 2060 2061 _sMethodId_nativeCb_fmRxCmdSetRdsSystem = env->GetStaticMethodID(clazz, 2062 "nativeCb_fmRxCmdSetRdsSystem", 2063 "(JIIJ)V"); 2064 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRdsSystem); 2065 2066 2067 _sMethodId_nativeCb_fmRxCmdSetRdsGroupMask = env->GetStaticMethodID(clazz, 2068 "nativeCb_fmRxCmdSetRdsGroupMask", 2069 "(JIIJ)V"); 2070 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRdsGroupMask); 2071 2072 2073 _sMethodId_nativeCb_fmRxCmdGetRdsGroupMask = env->GetStaticMethodID(clazz, 2074 "nativeCb_fmRxCmdGetRdsGroupMask", 2075 "(JIIJ)V"); 2076 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRdsGroupMask); 2077 2078 2079 _sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode = env->GetStaticMethodID(clazz, 2080 "nativeCb_fmRxCmdSetRdsAfSwitchMode", 2081 "(JIIJ)V"); 2082 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdSetRdsAfSwitchMode); 2083 2084 2085 _sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode = env->GetStaticMethodID(clazz, 2086 "nativeCb_fmRxCmdGetRdsAfSwitchMode", 2087 "(JIIJ)V"); 2088 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetRdsAfSwitchMode); 2089 2090 2091 _sMethodId_nativeCb_fmRxCmdDisableAudio = env->GetStaticMethodID(clazz, 2092 "nativeCb_fmRxCmdDisableAudio", 2093 "(JIIJ)V"); 2094 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDisableAudio); 2095 2096 _sMethodId_nativeCb_fmRxCmdDestroy = env->GetStaticMethodID(clazz, 2097 "nativeCb_fmRxCmdDestroy", 2098 "(JIIJ)V"); 2099 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdDestroy); 2100 2101 2102 _sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration= env->GetStaticMethodID(clazz, 2103 "nativeCb_fmRxCmdChangeDigitalAudioConfiguration", 2104 "(JIIJ)V"); 2105 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdChangeDigitalAudioConfiguration); 2106 2107 /* Complete scan in V4l2 FM driver is not implemented yet 2108 Commented the FM RX Completescan functionality start*/ 2109 2110 /*_sMethodId_nativeCb_fmRxCompleteScanDone = env->GetStaticMethodID(clazz, 2111 "nativeCb_fmRxCompleteScanDone", 2112 "(JII[I)V"); 2113 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCompleteScanDone);*/ 2114 2115 /*Commented the FM RX Completescan functionality end*/ 2116 2117 2118 _sMethodId_nativeCb_fmRxCmdGetFwVersion = env->GetStaticMethodID(clazz, 2119 "nativeCb_fmRxCmdGetFwVersion", 2120 "(JIIJ)V"); 2121 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetFwVersion); 2122 2123 _sMethodId_nativeCb_fmRxCmdIsValidChannel = env->GetStaticMethodID(clazz, 2124 "nativeCb_fmRxCmdIsValidChannel", 2125 "(JIIJ)V"); 2126 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdIsValidChannel); 2127 2128 2129 _sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress = env->GetStaticMethodID(clazz, 2130 "nativeCb_fmRxCmdGetCompleteScanProgress", 2131 "(JIIJ)V"); 2132 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdGetCompleteScanProgress); 2133 2134 _sMethodId_nativeCb_fmRxCmdStopCompleteScan = env->GetStaticMethodID(clazz, 2135 "nativeCb_fmRxCmdStopCompleteScan", 2136 "(JIIJ)V"); 2137 VERIFY_METHOD_ID(_sMethodId_nativeCb_fmRxCmdStopCompleteScan); 2138 2139 V4L2_JBTL_LOGD("nativeJFmRx_ClassInitNative:Exiting"); 2140 } 2141 2142 static JNINativeMethod JFmRxNative_sMethods[] = { 2143 /* name, signature, funcPtr */ 2144 {"nativeJFmRx_ClassInitNative", "()V", (void*)nativeJFmRx_ClassInitNative}, 2145 {"nativeJFmRx_Create", "(Lcom/ti/jfm/core/JFmContext;)I", (void*)nativeJFmRx_Create}, 2146 {"nativeJFmRx_Destroy", "(J)I", (void*)nativeJFmRx_Destroy}, 2147 {"nativeJFmRx_Enable", "(J)I", (void*)nativeJFmRx_Enable}, 2148 {"nativeJFmRx_Disable", "(J)I", (void*)nativeJFmRx_Disable}, 2149 {"nativeJFmRx_SetBand","(JI)I", (void*)nativeJFmRx_SetBand}, 2150 {"nativeJFmRx_GetBand","(J)I", (void*)nativeJFmRx_GetBand}, 2151 {"nativeJFmRx_Tune","(JI)I", (void*)nativeJFmRx_Tune}, 2152 {"nativeJFmRx_GetTunedFrequency","(J)I", (void*)nativeJFmRx_GetTunedFrequency}, 2153 {"nativeJFmRx_SetMonoStereoMode","(JI)I", (void*)nativeJFmRx_SetMonoStereoMode}, 2154 {"nativeJFmRx_GetMonoStereoMode","(J)I", (void*)nativeJFmRx_GetMonoStereoMode}, 2155 {"nativeJFmRx_SetMuteMode","(JI)I", (void*)nativeJFmRx_SetMuteMode}, 2156 {"nativeJFmRx_GetMuteMode","(J)I", (void*)nativeJFmRx_GetMuteMode}, 2157 {"nativeJFmRx_SetRssiThreshold","(JI)I", (void*)nativeJFmRx_SetRssiThreshold}, 2158 {"nativeJFmRx_GetRssiThreshold","(J)I", (void*)nativeJFmRx_GetRssiThreshold}, 2159 {"nativeJFmRx_GetRssi","(J)I", (void*)nativeJFmRx_GetRssi}, 2160 {"nativeJFmRx_SetVolume","(JI)I", (void*)nativeJFmRx_SetVolume}, 2161 {"nativeJFmRx_GetVolume","(J)I", (void*)nativeJFmRx_GetVolume}, 2162 {"nativeJFmRx_SetChannelSpacing","(JI)I", (void*)nativeJFmRx_SetChannelSpacing}, 2163 {"nativeJFmRx_GetChannelSpacing","(J)I", (void*)nativeJFmRx_GetChannelSpacing}, 2164 {"nativeJFmRx_SetDeEmphasisFilter","(JI)I", (void*)nativeJFmRx_SetDeEmphasisFilter}, 2165 {"nativeJFmRx_GetDeEmphasisFilter","(J)I", (void*)nativeJFmRx_GetDeEmphasisFilter}, 2166 {"nativeJFmRx_Seek","(JI)I", (void*)nativeJFmRx_Seek}, 2167 {"nativeJFmRx_StopSeek","(J)I", (void*)nativeJFmRx_StopSeek}, 2168 {"nativeJFmRx_EnableRDS","(J)I", (void*)nativeJFmRx_EnableRDS}, 2169 {"nativeJFmRx_DisableRDS","(J)I", (void*)nativeJFmRx_DisableRDS}, 2170 {"nativeJFmRx_EnableAudioRouting","(J)I", (void*)nativeJFmRx_EnableAudioRouting}, 2171 {"nativeJFmRx_DisableAudioRouting","(J)I", (void*)nativeJFmRx_DisableAudioRouting}, 2172 {"nativeJFmRx_SetRdsAfSwitchMode","(JI)I", (void*)nativeJFmRx_SetRdsAfSwitchMode}, 2173 {"nativeJFmRx_GetRdsAfSwitchMode","(J)I", (void*)nativeJFmRx_GetRdsAfSwitchMode}, 2174 {"nativeJFmRx_ChangeAudioTarget","(JII)I",(void*)nativeJFmRx_ChangeAudioTarget}, 2175 {"nativeJFmRx_ChangeDigitalTargetConfiguration","(JI)I",(void*)nativeJFmRx_ChangeDigitalTargetConfiguration}, 2176 {"nativeJFmRx_SetRfDependentMuteMode","(JI)I",(void*)nativeJFmRx_SetRfDependentMuteMode}, 2177 {"nativeJFmRx_GetRfDependentMute","(J)I",(void*)nativeJFmRx_GetRfDependentMute}, 2178 {"nativeJFmRx_SetRdsSystem","(JI)I",(void*)nativeJFmRx_SetRdsSystem}, 2179 {"nativeJFmRx_GetRdsSystem","(J)I",(void*)nativeJFmRx_GetRdsSystem}, 2180 {"nativeJFmRx_SetRdsGroupMask","(JJ)I",(void*)nativeJFmRx_SetRdsGroupMask}, 2181 {"nativeJFmRx_GetRdsGroupMask","(J)I",(void*)nativeJFmRx_GetRdsGroupMask}, 2182 {"nativeJFmRx_CompleteScan","(J)I",(void*)nativeJFmRx_CompleteScan}, 2183 {"nativeJFmRx_IsValidChannel","(J)I",(void*)nativeJFmRx_IsValidChannel}, 2184 {"nativeJFmRx_GetFwVersion","(J)I",(void*)nativeJFmRx_GetFwVersion}, 2185 {"nativeJFmRx_GetCompleteScanProgress","(J)I",(void*)nativeJFmRx_GetCompleteScanProgress}, 2186 {"nativeJFmRx_StopCompleteScan","(J)I",(void*)nativeJFmRx_StopCompleteScan}, 2187 2188 }; 2189 2190 /**********************************/ 2191 2192 2193 /* 2194 * Register several native methods for one class. 2195 */ 2196 static int registerNatives(JNIEnv* env, const char* className, 2197 JNINativeMethod* gMethods, int numMethods) 2198 { 2199 jclass clazz; 2200 2201 clazz = env->FindClass(className); 2202 if (clazz == NULL) { 2203 V4L2_JBTL_LOGD("Can not find class %s\n", className); 2204 return JNI_FALSE; 2205 } 2206 2207 if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) { 2208 V4L2_JBTL_LOGD("Can not RegisterNatives\n"); 2209 return JNI_FALSE; 2210 } 2211 2212 return JNI_TRUE; 2213 } 2214 2215 /*Commented the FM TX functionality start*/ 2216 2217 extern JNINativeMethod JFmTxNative_sMethods[]; 2218 extern int getTxNativeSize(); 2219 2220 /*Commented the FM TX functionality end*/ 2221 2222 jint JNI_OnLoad(JavaVM* vm, void* reserved) 2223 { 2224 JNIEnv* env = NULL; 2225 jint result = -1; 2226 2227 V4L2_JBTL_LOGD("OnLoad"); 2228 2229 if (vm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) { 2230 goto bail; 2231 } 2232 2233 if (!registerNatives(env, 2234 "com/ti/jfm/core/JFmRx", 2235 JFmRxNative_sMethods, 2236 NELEM(JFmRxNative_sMethods))) { 2237 goto bail; 2238 } 2239 2240 2241 if (!registerNatives(env, 2242 "com/ti/jfm/core/JFmTx", 2243 JFmTxNative_sMethods, 2244 getTxNativeSize())) { 2245 goto bail; 2246 } 2247 2248 2249 env->GetJavaVM(&g_jVM); 2250 2251 /* success -- return valid version number */ 2252 result = JNI_VERSION_1_4; 2253 2254 bail: 2255 return result; 2256 } 2257 2258 2259