1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.media.tv.tuner.frontend; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.SystemApi; 22 import android.hardware.tv.tuner.V1_0.Constants; 23 import android.media.tv.tuner.Lnb; 24 25 import java.lang.annotation.Retention; 26 import java.lang.annotation.RetentionPolicy; 27 28 /** 29 * Frontend status. 30 * 31 * @hide 32 */ 33 @SystemApi 34 public class FrontendStatus { 35 36 /** @hide */ 37 @IntDef({FRONTEND_STATUS_TYPE_DEMOD_LOCK, FRONTEND_STATUS_TYPE_SNR, FRONTEND_STATUS_TYPE_BER, 38 FRONTEND_STATUS_TYPE_PER, FRONTEND_STATUS_TYPE_PRE_BER, 39 FRONTEND_STATUS_TYPE_SIGNAL_QUALITY, FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH, 40 FRONTEND_STATUS_TYPE_SYMBOL_RATE, FRONTEND_STATUS_TYPE_FEC, 41 FRONTEND_STATUS_TYPE_MODULATION, FRONTEND_STATUS_TYPE_SPECTRAL, 42 FRONTEND_STATUS_TYPE_LNB_VOLTAGE, FRONTEND_STATUS_TYPE_PLP_ID, 43 FRONTEND_STATUS_TYPE_EWBS, FRONTEND_STATUS_TYPE_AGC, FRONTEND_STATUS_TYPE_LNA, 44 FRONTEND_STATUS_TYPE_LAYER_ERROR, FRONTEND_STATUS_TYPE_MER, 45 FRONTEND_STATUS_TYPE_FREQ_OFFSET, FRONTEND_STATUS_TYPE_HIERARCHY, 46 FRONTEND_STATUS_TYPE_RF_LOCK, FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO}) 47 @Retention(RetentionPolicy.SOURCE) 48 public @interface FrontendStatusType {} 49 50 /** 51 * Lock status for Demod. 52 */ 53 public static final int FRONTEND_STATUS_TYPE_DEMOD_LOCK = 54 Constants.FrontendStatusType.DEMOD_LOCK; 55 /** 56 * Signal to Noise Ratio. 57 */ 58 public static final int FRONTEND_STATUS_TYPE_SNR = Constants.FrontendStatusType.SNR; 59 /** 60 * Bit Error Ratio. 61 */ 62 public static final int FRONTEND_STATUS_TYPE_BER = Constants.FrontendStatusType.BER; 63 /** 64 * Packages Error Ratio. 65 */ 66 public static final int FRONTEND_STATUS_TYPE_PER = Constants.FrontendStatusType.PER; 67 /** 68 * Bit Error Ratio before FEC. 69 */ 70 public static final int FRONTEND_STATUS_TYPE_PRE_BER = Constants.FrontendStatusType.PRE_BER; 71 /** 72 * Signal Quality (0..100). Good data over total data in percent can be 73 * used as a way to present Signal Quality. 74 */ 75 public static final int FRONTEND_STATUS_TYPE_SIGNAL_QUALITY = 76 Constants.FrontendStatusType.SIGNAL_QUALITY; 77 /** 78 * Signal Strength. 79 */ 80 public static final int FRONTEND_STATUS_TYPE_SIGNAL_STRENGTH = 81 Constants.FrontendStatusType.SIGNAL_STRENGTH; 82 /** 83 * Symbol Rate in symbols per second. 84 */ 85 public static final int FRONTEND_STATUS_TYPE_SYMBOL_RATE = 86 Constants.FrontendStatusType.SYMBOL_RATE; 87 /** 88 * Forward Error Correction Type. 89 */ 90 public static final int FRONTEND_STATUS_TYPE_FEC = Constants.FrontendStatusType.FEC; 91 /** 92 * Modulation Type. 93 */ 94 public static final int FRONTEND_STATUS_TYPE_MODULATION = 95 Constants.FrontendStatusType.MODULATION; 96 /** 97 * Spectral Inversion Type. 98 */ 99 public static final int FRONTEND_STATUS_TYPE_SPECTRAL = Constants.FrontendStatusType.SPECTRAL; 100 /** 101 * LNB Voltage. 102 */ 103 public static final int FRONTEND_STATUS_TYPE_LNB_VOLTAGE = 104 Constants.FrontendStatusType.LNB_VOLTAGE; 105 /** 106 * Physical Layer Pipe ID. 107 */ 108 public static final int FRONTEND_STATUS_TYPE_PLP_ID = Constants.FrontendStatusType.PLP_ID; 109 /** 110 * Status for Emergency Warning Broadcasting System. 111 */ 112 public static final int FRONTEND_STATUS_TYPE_EWBS = Constants.FrontendStatusType.EWBS; 113 /** 114 * Automatic Gain Control. 115 */ 116 public static final int FRONTEND_STATUS_TYPE_AGC = Constants.FrontendStatusType.AGC; 117 /** 118 * Low Noise Amplifier. 119 */ 120 public static final int FRONTEND_STATUS_TYPE_LNA = Constants.FrontendStatusType.LNA; 121 /** 122 * Error status by layer. 123 */ 124 public static final int FRONTEND_STATUS_TYPE_LAYER_ERROR = 125 Constants.FrontendStatusType.LAYER_ERROR; 126 /** 127 * Modulation Error Ratio. 128 */ 129 public static final int FRONTEND_STATUS_TYPE_MER = Constants.FrontendStatusType.MER; 130 /** 131 * Difference between tuning frequency and actual locked frequency. 132 */ 133 public static final int FRONTEND_STATUS_TYPE_FREQ_OFFSET = 134 Constants.FrontendStatusType.FREQ_OFFSET; 135 /** 136 * Hierarchy for DVBT. 137 */ 138 public static final int FRONTEND_STATUS_TYPE_HIERARCHY = Constants.FrontendStatusType.HIERARCHY; 139 /** 140 * Lock status for RF. 141 */ 142 public static final int FRONTEND_STATUS_TYPE_RF_LOCK = Constants.FrontendStatusType.RF_LOCK; 143 /** 144 * PLP information in a frequency band for ATSC-3.0 frontend. 145 */ 146 public static final int FRONTEND_STATUS_TYPE_ATSC3_PLP_INFO = 147 Constants.FrontendStatusType.ATSC3_PLP_INFO; 148 149 150 /** @hide */ 151 @IntDef(value = { 152 DvbcFrontendSettings.MODULATION_UNDEFINED, 153 DvbcFrontendSettings.MODULATION_AUTO, 154 DvbcFrontendSettings.MODULATION_MOD_16QAM, 155 DvbcFrontendSettings.MODULATION_MOD_32QAM, 156 DvbcFrontendSettings.MODULATION_MOD_64QAM, 157 DvbcFrontendSettings.MODULATION_MOD_128QAM, 158 DvbcFrontendSettings.MODULATION_MOD_256QAM, 159 DvbsFrontendSettings.MODULATION_UNDEFINED, 160 DvbsFrontendSettings.MODULATION_AUTO, 161 DvbsFrontendSettings.MODULATION_MOD_QPSK, 162 DvbsFrontendSettings.MODULATION_MOD_8PSK, 163 DvbsFrontendSettings.MODULATION_MOD_16QAM, 164 DvbsFrontendSettings.MODULATION_MOD_16PSK, 165 DvbsFrontendSettings.MODULATION_MOD_32PSK, 166 DvbsFrontendSettings.MODULATION_MOD_ACM, 167 DvbsFrontendSettings.MODULATION_MOD_8APSK, 168 DvbsFrontendSettings.MODULATION_MOD_16APSK, 169 DvbsFrontendSettings.MODULATION_MOD_32APSK, 170 DvbsFrontendSettings.MODULATION_MOD_64APSK, 171 DvbsFrontendSettings.MODULATION_MOD_128APSK, 172 DvbsFrontendSettings.MODULATION_MOD_256APSK, 173 DvbsFrontendSettings.MODULATION_MOD_RESERVED, 174 IsdbsFrontendSettings.MODULATION_UNDEFINED, 175 IsdbsFrontendSettings.MODULATION_AUTO, 176 IsdbsFrontendSettings.MODULATION_MOD_BPSK, 177 IsdbsFrontendSettings.MODULATION_MOD_QPSK, 178 IsdbsFrontendSettings.MODULATION_MOD_TC8PSK, 179 Isdbs3FrontendSettings.MODULATION_UNDEFINED, 180 Isdbs3FrontendSettings.MODULATION_AUTO, 181 Isdbs3FrontendSettings.MODULATION_MOD_BPSK, 182 Isdbs3FrontendSettings.MODULATION_MOD_QPSK, 183 Isdbs3FrontendSettings.MODULATION_MOD_8PSK, 184 Isdbs3FrontendSettings.MODULATION_MOD_16APSK, 185 Isdbs3FrontendSettings.MODULATION_MOD_32APSK, 186 IsdbtFrontendSettings.MODULATION_UNDEFINED, 187 IsdbtFrontendSettings.MODULATION_AUTO, 188 IsdbtFrontendSettings.MODULATION_MOD_DQPSK, 189 IsdbtFrontendSettings.MODULATION_MOD_QPSK, 190 IsdbtFrontendSettings.MODULATION_MOD_16QAM, 191 IsdbtFrontendSettings.MODULATION_MOD_64QAM}) 192 @Retention(RetentionPolicy.SOURCE) 193 public @interface FrontendModulation {} 194 195 196 private Boolean mIsDemodLocked; 197 private Integer mSnr; 198 private Integer mBer; 199 private Integer mPer; 200 private Integer mPerBer; 201 private Integer mSignalQuality; 202 private Integer mSignalStrength; 203 private Integer mSymbolRate; 204 private Long mInnerFec; 205 private Integer mModulation; 206 private Integer mInversion; 207 private Integer mLnbVoltage; 208 private Integer mPlpId; 209 private Boolean mIsEwbs; 210 private Integer mAgc; 211 private Boolean mIsLnaOn; 212 private boolean[] mIsLayerErrors; 213 private Integer mMer; 214 private Integer mFreqOffset; 215 private Integer mHierarchy; 216 private Boolean mIsRfLocked; 217 private Atsc3PlpTuningInfo[] mPlpInfo; 218 219 // Constructed and fields set by JNI code. FrontendStatus()220 private FrontendStatus() { 221 } 222 223 /** 224 * Lock status for Demod. 225 */ isDemodLocked()226 public boolean isDemodLocked() { 227 if (mIsDemodLocked == null) { 228 throw new IllegalStateException(); 229 } 230 return mIsDemodLocked; 231 } 232 /** 233 * Gets Signal to Noise Ratio in thousandths of a deciBel (0.001dB). 234 */ getSnr()235 public int getSnr() { 236 if (mSnr == null) { 237 throw new IllegalStateException(); 238 } 239 return mSnr; 240 } 241 /** 242 * Gets Bit Error Ratio. 243 * 244 * <p>The number of error bit per 1 billion bits. 245 */ getBer()246 public int getBer() { 247 if (mBer == null) { 248 throw new IllegalStateException(); 249 } 250 return mBer; 251 } 252 253 /** 254 * Gets Packages Error Ratio. 255 * 256 * <p>The number of error package per 1 billion packages. 257 */ getPer()258 public int getPer() { 259 if (mPer == null) { 260 throw new IllegalStateException(); 261 } 262 return mPer; 263 } 264 /** 265 * Gets Bit Error Ratio before Forward Error Correction (FEC). 266 * 267 * <p>The number of error bit per 1 billion bits before FEC. 268 */ getPerBer()269 public int getPerBer() { 270 if (mPerBer == null) { 271 throw new IllegalStateException(); 272 } 273 return mPerBer; 274 } 275 /** 276 * Gets Signal Quality in percent. 277 */ getSignalQuality()278 public int getSignalQuality() { 279 if (mSignalQuality == null) { 280 throw new IllegalStateException(); 281 } 282 return mSignalQuality; 283 } 284 /** 285 * Gets Signal Strength in thousandths of a dBm (0.001dBm). 286 */ getSignalStrength()287 public int getSignalStrength() { 288 if (mSignalStrength == null) { 289 throw new IllegalStateException(); 290 } 291 return mSignalStrength; 292 } 293 /** 294 * Gets symbol rate in symbols per second. 295 */ getSymbolRate()296 public int getSymbolRate() { 297 if (mSymbolRate == null) { 298 throw new IllegalStateException(); 299 } 300 return mSymbolRate; 301 } 302 /** 303 * Gets Inner Forward Error Correction type as specified in ETSI EN 300 468 V1.15.1 304 * and ETSI EN 302 307-2 V1.1.1. 305 */ 306 @FrontendSettings.InnerFec getInnerFec()307 public long getInnerFec() { 308 if (mInnerFec == null) { 309 throw new IllegalStateException(); 310 } 311 return mInnerFec; 312 } 313 /** 314 * Gets modulation. 315 */ 316 @FrontendModulation getModulation()317 public int getModulation() { 318 if (mModulation == null) { 319 throw new IllegalStateException(); 320 } 321 return mModulation; 322 } 323 /** 324 * Gets Spectral Inversion for DVBC. 325 */ 326 @DvbcFrontendSettings.SpectralInversion getSpectralInversion()327 public int getSpectralInversion() { 328 if (mInversion == null) { 329 throw new IllegalStateException(); 330 } 331 return mInversion; 332 } 333 /** 334 * Gets Power Voltage Type for LNB. 335 */ 336 @Lnb.Voltage getLnbVoltage()337 public int getLnbVoltage() { 338 if (mLnbVoltage == null) { 339 throw new IllegalStateException(); 340 } 341 return mLnbVoltage; 342 } 343 /** 344 * Gets Physical Layer Pipe ID. 345 */ getPlpId()346 public int getPlpId() { 347 if (mPlpId == null) { 348 throw new IllegalStateException(); 349 } 350 return mPlpId; 351 } 352 /** 353 * Checks whether it's Emergency Warning Broadcasting System 354 */ isEwbs()355 public boolean isEwbs() { 356 if (mIsEwbs == null) { 357 throw new IllegalStateException(); 358 } 359 return mIsEwbs; 360 } 361 /** 362 * Gets Automatic Gain Control value which is normalized from 0 to 255. 363 */ getAgc()364 public int getAgc() { 365 if (mAgc == null) { 366 throw new IllegalStateException(); 367 } 368 return mAgc; 369 } 370 /** 371 * Checks LNA (Low Noise Amplifier) is on or not. 372 */ isLnaOn()373 public boolean isLnaOn() { 374 if (mIsLnaOn == null) { 375 throw new IllegalStateException(); 376 } 377 return mIsLnaOn; 378 } 379 /** 380 * Gets Error status by layer. 381 */ 382 @NonNull getLayerErrors()383 public boolean[] getLayerErrors() { 384 if (mIsLayerErrors == null) { 385 throw new IllegalStateException(); 386 } 387 return mIsLayerErrors; 388 } 389 /** 390 * Gets Modulation Error Ratio in thousandths of a deciBel (0.001dB). 391 */ getMer()392 public int getMer() { 393 if (mMer == null) { 394 throw new IllegalStateException(); 395 } 396 return mMer; 397 } 398 /** 399 * Gets frequency difference in Hz. 400 * 401 * <p>Difference between tuning frequency and actual locked frequency. 402 */ getFreqOffset()403 public int getFreqOffset() { 404 if (mFreqOffset == null) { 405 throw new IllegalStateException(); 406 } 407 return mFreqOffset; 408 } 409 /** 410 * Gets hierarchy Type for DVBT. 411 */ 412 @DvbtFrontendSettings.Hierarchy getHierarchy()413 public int getHierarchy() { 414 if (mHierarchy == null) { 415 throw new IllegalStateException(); 416 } 417 return mHierarchy; 418 } 419 /** 420 * Gets lock status for RF. 421 */ isRfLocked()422 public boolean isRfLocked() { 423 if (mIsRfLocked == null) { 424 throw new IllegalStateException(); 425 } 426 return mIsRfLocked; 427 } 428 /** 429 * Gets an array of PLP status for tuned PLPs for ATSC3 frontend. 430 */ 431 @NonNull getAtsc3PlpTuningInfo()432 public Atsc3PlpTuningInfo[] getAtsc3PlpTuningInfo() { 433 if (mPlpInfo == null) { 434 throw new IllegalStateException(); 435 } 436 return mPlpInfo; 437 } 438 439 /** 440 * Status for each tuning Physical Layer Pipes. 441 */ 442 public static class Atsc3PlpTuningInfo { 443 private final int mPlpId; 444 private final boolean mIsLocked; 445 private final int mUec; 446 Atsc3PlpTuningInfo(int plpId, boolean isLocked, int uec)447 private Atsc3PlpTuningInfo(int plpId, boolean isLocked, int uec) { 448 mPlpId = plpId; 449 mIsLocked = isLocked; 450 mUec = uec; 451 } 452 453 /** 454 * Gets Physical Layer Pipe ID. 455 */ getPlpId()456 public int getPlpId() { 457 return mPlpId; 458 } 459 /** 460 * Gets Demod Lock/Unlock status of this particular PLP. 461 */ isLocked()462 public boolean isLocked() { 463 return mIsLocked; 464 } 465 /** 466 * Gets Uncorrectable Error Counts (UEC) of this particular PLP since last tune operation. 467 */ getUec()468 public int getUec() { 469 return mUec; 470 } 471 } 472 } 473