ANDROIDFM Module Learning four source code analysis (10)

Source: Internet
Author: User

Next, let's take a look at Android\vendor\qcom\opensource\fm\qcom\fmradio\fmrxcontrols.java today.

/ *

* Open FM RX/TX.

* Rx = 1 and tx = 2

* /

public void Fmon (int fd, int device) {      int re;      Fmreceiverjni.setcontrolnative (FD, v4l2_cid_private_tavarua_state, device);      Setaudiopath (fd, false);      Re = fmreceiverjni.setcalibrationnative (FD);      if (Re! = 0)         log.d (TAG, "calibration failed");   }

/ *

* Turn off the FM RX/TX

* /

public void Fmoff (int fd) {      fmreceiverjni.setcontrolnative (fd, v4l2_cid_private_tavarua_state, 0);   }

/ *

* Set Mute control

* /

public void Mutecontrol (Int. fd, Boolean on) {      if (on)      {         int err = fmreceiverjni.setcontrolnative (FD, V4l2_cid _audio_mute, 3);      } else      {         int err = fmreceiverjni.setcontrolnative (fd, V4l2_cid_audio_mute, 0);      }   }

/ *

* Get interference Channel

* /

public int Ioverccontrol (int fd)   {      int ioverc = fmreceiverjni.getcontrolnative (FD, V4l2_cid_private_tavarua_ IOVERC);      LOG.D (TAG, "Ioverc value is:" +ioverc);      return IOVERC;   }

/ *

* Get Intdet

* /

public int Intdet (int fd)   {      int intdet =  fmreceiverjni.getcontrolnative (FD, V4l2_cid_private_tavarua_ Intdet);      LOG.D (TAG, "Ioverc value is:" +intdet);      return intdet;   }

/ *

* Get MPX_DCC

* /

public int MPX_DCC (int fd)   {      int mpx_dcc =  fmreceiverjni.getcontrolnative (FD, V4l2_cid_private_tavarua_ MPX_DCC);      LOG.D (TAG, "MPX_DCC value is:" + MPX_DCC);      return MPX_DCC;   }

/ *

* Set Hi-low Injection

* /

public int Sethiloinj (int fd, INT inj)   {      int re =  fmreceiverjni.setcontrolnative (FD, V4l2_cid_private_ TAVARUA_HLSI, inj);      return re;   }

/ *

*set Open channel threshold value

* /

public int setonchannelthreshold (int fd, int sbuff)   {      int re = fmreceiverjni.setcontrolnative (FD, V4l2_cid_ Private_tavarua_on_channel_threshold, Sbuff);      if (re < 0)         log.e (TAG, "Failed to set on channel threshold Data");      return re;   }

/ *

*set closing the channel threshold value

* /

public int setoffchannelthreshold (int fd, int sbuff)   {      int re = fmreceiverjni.setcontrolnative (FD, V4l2_cid_ Private_tavarua_off_channel_threshold, Sbuff);      if (re < 0)         log.e (TAG, "Failed to set OFF channel Threshold data");      return re;   }

/ *

* Set audio path analog/digital

* /

public int Setaudiopath (int fd, Boolean value)   {      int mode;      if (value)         mode = Fm_analog_path;      else         mode = Fm_digital_path;      int re =  fmreceiverjni.setcontrolnative (FD, V4l2_cid_private_tavarua_set_audio_path, mode);      return re;   }

/ *

* Optimize the frequency specified by the FM core.

* /

public int setstation (int fd) {      log.d (TAG, "* * Tune Using:" +FD);      int ret = fmreceiverjni.setfreqnative (FD, mfreq);      LOG.D (TAG, "* * returned:" +ret);      return ret;   }

/ *

* Get FM frequency

* /

public int gettunedfrequency (int fd) {
int frequency = fmreceiverjni.getfreqnative (FD);
LOG.D (TAG, "gettunedfrequency:" +frequency);
return frequency;
}

/ *

* Gain the value of SINR

* /

public int Getsinr (int fd)   {      return  fmreceiverjni.getcontrolnative (FD, V4L2_CID_PRIVATE_SINR);   }

/ *

* Start Auto Search presets List

* /

public int searchstationlist (int fd, int mode, int preset_num, int dir, int pty) {     int re; /* Set search mode.      */re = fmreceiverjni.setcontrolnative (FD, V4l2_cid_private_tavarua_srchmode, mode);      if (Re! = 0) {return re; }/* Set number of stations to being returned in the list */re = Fmreceiverjni.setcontrolnative (FD, V4l2_cid_private_ta      VARUA_SRCH_CNT, Preset_num);      if (Re! = 0) {return re;      }//RDS search list?      if (Pty > 0) {re = fmreceiverjni.setcontrolnative (FD, V4l2_cid_private_tavarua_srch_pty, Pty);      } if (Re! = 0) {return re; }/* This triigers the search and once completed the FM core generates * Searchlistcomplete event */re =      Fmreceiverjni.startsearchnative (fd, dir);      if (Re! = 0) {return re;      } else {return 0; }   }

/* Read the search list from the buffer */

Public int[] Stationlist (int fd) {int freq = 0;         int i=0, j = 0;         int station_num = 0;         float real_freq = 0;         int [] stationlist;         byte [] sList = new byte[100];         int tmpfreqbyte1=0;         int tmpfreqbyte2=0;         float Lowband, Highband;         Lowband = (float) (fmreceiverjni.getlowerbandnative (FD)/1000.00);         Highband = (float) (fmreceiverjni.getupperbandnative (FD)/1000.00);         LOG.D (TAG, "Lowband:" + Lowband);         LOG.D (TAG, "Highband:" + Highband);         Fmreceiverjni.getbuffernative (FD, sList, 0);         if ((int) slist[0] >0) {station_num = (int) slist[0]; } stationlist = new int[station_num+1];         LOG.D (TAG, "station_num:" + station_num);            for (i=0;i<station_num;i++) {freq = 0;            LOG.D (TAG, "Byte1 =" + slist[i*2+1]);            LOG.D (TAG, "Byte2 =" + slist[i*2+2]);            TmpFreqByte1 = slist[i*2+1] & 0xFF; TmpfreqbYte2 = slist[i*2+2] & 0xFF;            LOG.D (TAG, "tmpFreqByte1 =" + tmpFreqByte1);            LOG.D (TAG, "tmpFreqByte2 =" + TmpFreqByte2);            Freq = (tmpFreqByte1 & 0x03) << 8;            Freq |= TmpFreqByte2;            LOG.D (TAG, "freq:" + freq); real_freq = (float) (Freq *) + (Lowband * freq_mul);//tuner.rangelow * FREQ_MUL;            LOG.D (TAG, "real_freq:" + real_freq); if ((Real_freq < (Lowband * freq_mul)) | | (Real_freq > (Highband * freq_mul)))            {LOG.E (TAG, "Frequency out of Band Limits");               } else {stationlist[j] = (int) (REAL_FREQ);               LOG.D (TAG, "stationlist:" + stationlist[j]);            j + +;        }} try {//Mark end of list stationlist[station_num] = 0;        } catch (ArrayIndexOutOfBoundsException e) {log.d (TAG, "ArrayIndexOutOfBoundsException!");   } return stationlist; }


ANDROIDFM Module Learning four source code analysis (10)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.