Venkateshwarlu Domakonda | aa25363 | 2013-03-25 16:53:03 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are met: |
| 6 | * * Redistributions of source code must retain the above copyright |
| 7 | * notice, this list of conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer in the |
| 10 | * documentation and/or other materials provided with the distribution. |
| 11 | * * Neither the name of The Linux Foundation nor |
| 12 | * the names of its contributors may be used to endorse or promote |
| 13 | * products derived from this software without specific prior written |
| 14 | * permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 20 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | package qcom.fmradio; |
| 30 | |
| 31 | class FmReceiverJNI { |
| 32 | /** |
| 33 | * General success |
| 34 | */ |
| 35 | static final int FM_JNI_SUCCESS = 0; |
| 36 | |
| 37 | /** |
| 38 | * General failure |
| 39 | */ |
| 40 | static final int FM_JNI_FAILURE = -1; |
| 41 | |
| 42 | /** |
| 43 | * native method: Open device |
| 44 | * @return The file descriptor of the device |
| 45 | * |
| 46 | */ |
| 47 | static native int acquireFdNative(String path); |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * native method: |
| 52 | * @param fd |
| 53 | * @param control |
| 54 | * @param field |
| 55 | * @return |
| 56 | */ |
| 57 | static native int audioControlNative(int fd, int control, int field); |
| 58 | |
| 59 | /** |
| 60 | * native method: cancels search |
| 61 | * @param fd file descriptor of device |
| 62 | * @return May return |
| 63 | * {@link #FM_JNI_SUCCESS} |
| 64 | * {@link #FM_JNI_FAILURE} |
| 65 | */ |
| 66 | static native int cancelSearchNative(int fd); |
| 67 | |
| 68 | /** |
| 69 | * native method: release control of device |
| 70 | * @param fd file descriptor of device |
| 71 | * @return May return |
| 72 | * {@link #FM_JNI_SUCCESS} |
| 73 | * {@link #FM_JNI_FAILURE} |
| 74 | */ |
| 75 | static native int closeFdNative(int fd); |
| 76 | |
| 77 | /** |
| 78 | * native method: get frequency |
| 79 | * @param fd file descriptor of device |
| 80 | * @return Returns frequency in int form |
| 81 | */ |
| 82 | static native int getFreqNative(int fd); |
| 83 | |
| 84 | /** |
| 85 | * native method: set frequency |
| 86 | * @param fd file descriptor of device |
| 87 | * @param freq freq to be set in int form |
| 88 | * @return {@link #FM_JNI_SUCCESS} |
| 89 | * {@link #FM_JNI_FAILURE} |
| 90 | * |
| 91 | */ |
| 92 | static native int setFreqNative(int fd, int freq); |
| 93 | |
| 94 | /** |
| 95 | * native method: get v4l2 control |
| 96 | * @param fd file descriptor of device |
| 97 | * @param id v4l2 id to be retrieved |
| 98 | * @return Returns current value of the |
| 99 | * v4l2 control |
| 100 | */ |
| 101 | static native int getControlNative (int fd, int id); |
| 102 | |
| 103 | /** |
| 104 | * native method: set v4l2 control |
| 105 | * @param fd file descriptor of device |
| 106 | * @param id v4l2 control to be set |
| 107 | * @param value value to be set |
| 108 | * @return {@link #FM_JNI_SUCCESS} |
| 109 | * {@link #FM_JNI_FAILURE} |
| 110 | */ |
| 111 | static native int setControlNative (int fd, int id, int value); |
| 112 | |
| 113 | /** |
| 114 | * native method: start search |
| 115 | * @param fd file descriptor of device |
| 116 | * @param dir search direction |
| 117 | * @return {@link #FM_JNI_SUCCESS} |
| 118 | * {@link #FM_JNI_FAILURE} |
| 119 | */ |
| 120 | static native int startSearchNative (int fd, int dir); |
| 121 | |
| 122 | /** |
| 123 | * native method: get buffer |
| 124 | * @param fd file descriptor of device |
| 125 | * @param buff[] buffer |
| 126 | * @param index index of the buffer to be retrieved |
| 127 | * @return {@link #FM_JNI_SUCCESS} |
| 128 | * {@link #FM_JNI_FAILURE} |
| 129 | */ |
| 130 | static native int getBufferNative (int fd, byte buff[], int index); |
| 131 | |
| 132 | /** |
| 133 | * native method: get RSSI value of the |
| 134 | * received signal |
| 135 | * @param fd file descriptor of device |
| 136 | * @return Returns signal strength in int form |
| 137 | * Signal value range from -120 to 10 |
| 138 | */ |
| 139 | static native int getRSSINative (int fd); |
| 140 | |
| 141 | /** |
| 142 | * native method: set FM band |
| 143 | * @param fd file descriptor of device |
| 144 | * @param low lower band |
| 145 | * @param high higher band |
| 146 | * @return {@link #FM_JNI_SUCCESS} |
| 147 | * {@link #FM_JNI_FAILURE} |
| 148 | */ |
| 149 | static native int setBandNative (int fd, int low, int high); |
| 150 | |
| 151 | /** |
| 152 | * native method: get lower band |
| 153 | * @param fd file descriptor of device |
| 154 | * @return Returns lower band in int form |
| 155 | */ |
| 156 | static native int getLowerBandNative (int fd); |
| 157 | |
| 158 | /** |
| 159 | * native method: get upper band |
| 160 | * @param fd file descriptor of device |
| 161 | * @return Returns upper band in int form |
| 162 | */ |
| 163 | static native int getUpperBandNative (int fd); |
| 164 | |
| 165 | /** |
| 166 | * native method: force Mono/Stereo mode |
| 167 | * @param fd file descriptor of device |
| 168 | * @param val force mono/stereo indicator |
| 169 | * @return {@link #FM_JNI_SUCCESS} |
| 170 | * {@link #FM_JNI_FAILURE} |
| 171 | */ |
| 172 | static native int setMonoStereoNative (int fd, int val); |
| 173 | |
| 174 | /** |
| 175 | * native method: get Raw RDS data |
| 176 | * @param fd file descriptor of device |
| 177 | * @param buff[] buffer |
| 178 | * @param count number of bytes to be read |
| 179 | * @return Returns number of bytes read |
| 180 | */ |
| 181 | static native int getRawRdsNative (int fd, byte buff[], int count); |
| 182 | |
| 183 | /** |
| 184 | * native method: set v4l2 control |
| 185 | * @param fd file descriptor of device |
| 186 | * @param id v4l2 control to be set |
| 187 | * @param value value to be set |
| 188 | * @return {@link #FM_JNI_SUCCESS} |
| 189 | * {@link #FM_JNI_FAILURE} |
| 190 | */ |
| 191 | static native int setNotchFilterNative(int fd, int id, boolean value); |
| 192 | |
| 193 | /** |
| 194 | * native method: enable/disable Analog Mode |
| 195 | */ |
| 196 | static native int setAnalogModeNative(boolean value); |
| 197 | |
| 198 | /** |
| 199 | * native method: Starts the RT transmission |
| 200 | * @param fd file descriptor of device |
| 201 | * @param buff[] buffer |
| 202 | * @param count number of bytes to be read |
| 203 | * @return Returns number of bytes read |
| 204 | */ |
| 205 | static native int startRTNative(int fd, String str, int count); |
| 206 | |
| 207 | /** |
| 208 | * native method: Stops the RT transmission |
| 209 | * @param fd file descriptor of device |
| 210 | * @param buff[] buffer |
| 211 | * @param count number of bytes to be read |
| 212 | * @return Returns number of bytes read |
| 213 | */ |
| 214 | static native int stopRTNative(int fd); |
| 215 | |
| 216 | /** |
| 217 | * native method: Starts the PS transmission |
| 218 | * @param fd file descriptor of device |
| 219 | * @param buff[] buffer |
| 220 | * @param count number of bytes to be read |
| 221 | * @return Returns number of bytes read |
| 222 | */ |
| 223 | static native int startPSNative(int fd, String str, int count); |
| 224 | |
| 225 | /** |
| 226 | * native method: Stops the PS transmission |
| 227 | * @param fd file descriptor of device |
| 228 | * @param buff[] buffer |
| 229 | * @param count number of bytes to be read |
| 230 | */ |
| 231 | static native int stopPSNative(int fd); |
| 232 | /** |
| 233 | * native method: Sets the Programme type for transmission |
| 234 | * @param fd file descriptor of device |
| 235 | * @param pty program type to be transmited |
| 236 | * @return {@link #FM_JNI_SUCCESS} |
| 237 | * {@link #FM_JNI_FAILURE} |
| 238 | */ |
| 239 | static native int setPTYNative (int fd, int pty); |
| 240 | |
| 241 | /** |
| 242 | * native method: Sets the Programme Id for transmission |
| 243 | * @param fd file descriptor of device |
| 244 | * @param pty program Id to be transmited |
| 245 | * @return {@link #FM_JNI_SUCCESS} |
| 246 | * {@link #FM_JNI_FAILURE} |
| 247 | */ |
| 248 | static native int setPINative (int fd, int pi); |
| 249 | |
| 250 | |
| 251 | /** |
| 252 | * native method: Sets the repeat count for Programme service |
| 253 | * transmission. |
| 254 | * @param fd file descriptor of device |
| 255 | * @param repeatcount number of times PS string to be transmited |
| 256 | * repeatedly. |
| 257 | * @return {@link #FM_JNI_SUCCESS} |
| 258 | * {@link #FM_JNI_FAILURE} |
| 259 | */ |
| 260 | static native int setPSRepeatCountNative(int fd, int repeatCount); |
| 261 | /** |
| 262 | * native method: Sets the power level for the tramsmitter |
| 263 | * transmission. |
| 264 | * @param fd file descriptor of device |
| 265 | * @param powLevel is the level at which transmitter operates. |
| 266 | * @return {@link #FM_JNI_SUCCESS} |
| 267 | * {@link #FM_JNI_FAILURE} |
| 268 | */ |
| 269 | static native int setTxPowerLevelNative(int fd, int powLevel); |
| 270 | /** |
| 271 | * native method: Sets the calibration |
| 272 | * @param fd file descriptor of device |
| 273 | * @return {@link #FM_JNI_SUCCESS} |
| 274 | * {@link #FM_JNI_FAILURE} |
| 275 | */ |
| 276 | static native int SetCalibrationNative(int fd); |
| 277 | |
| 278 | /** |
| 279 | * native method: Configures the spur table |
| 280 | * @param fd file descriptor of device |
| 281 | * @return {@link #FM_JNI_SUCCESS} |
| 282 | * {@link #FM_JNI_FAILURE} |
| 283 | */ |
| 284 | static native int configureSpurTable(int fd); |
| 285 | } |