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.IntRange; 21 import android.annotation.NonNull; 22 import android.annotation.SystemApi; 23 import android.hardware.tv.tuner.V1_0.Constants; 24 25 import java.lang.annotation.Retention; 26 import java.lang.annotation.RetentionPolicy; 27 28 /** 29 * Frontend settings for DVBC. 30 * 31 * @hide 32 */ 33 @SystemApi 34 public class DvbcFrontendSettings extends FrontendSettings { 35 36 /** @hide */ 37 @IntDef(flag = true, 38 prefix = "MODULATION_", 39 value = {MODULATION_UNDEFINED, MODULATION_AUTO, MODULATION_MOD_16QAM, 40 MODULATION_MOD_32QAM, MODULATION_MOD_64QAM, MODULATION_MOD_128QAM, 41 MODULATION_MOD_256QAM}) 42 @Retention(RetentionPolicy.SOURCE) 43 public @interface Modulation {} 44 45 /** 46 * Modulation undefined. 47 */ 48 public static final int MODULATION_UNDEFINED = Constants.FrontendDvbcModulation.UNDEFINED; 49 /** 50 * Hardware is able to detect and set modulation automatically 51 */ 52 public static final int MODULATION_AUTO = Constants.FrontendDvbcModulation.AUTO; 53 /** 54 * 16QAM Modulation. 55 */ 56 public static final int MODULATION_MOD_16QAM = Constants.FrontendDvbcModulation.MOD_16QAM; 57 /** 58 * 32QAM Modulation. 59 */ 60 public static final int MODULATION_MOD_32QAM = Constants.FrontendDvbcModulation.MOD_32QAM; 61 /** 62 * 64QAM Modulation. 63 */ 64 public static final int MODULATION_MOD_64QAM = Constants.FrontendDvbcModulation.MOD_64QAM; 65 /** 66 * 128QAM Modulation. 67 */ 68 public static final int MODULATION_MOD_128QAM = Constants.FrontendDvbcModulation.MOD_128QAM; 69 /** 70 * 256QAM Modulation. 71 */ 72 public static final int MODULATION_MOD_256QAM = Constants.FrontendDvbcModulation.MOD_256QAM; 73 74 /** @hide */ 75 @Retention(RetentionPolicy.SOURCE) 76 @IntDef(prefix = "OUTER_FEC_", 77 value = {OUTER_FEC_UNDEFINED, OUTER_FEC_OUTER_FEC_NONE, OUTER_FEC_OUTER_FEC_RS}) 78 public @interface OuterFec {} 79 80 /** 81 * Outer Forward Error Correction (FEC) Type undefined. 82 */ 83 public static final int OUTER_FEC_UNDEFINED = Constants.FrontendDvbcOuterFec.UNDEFINED; 84 /** 85 * None Outer Forward Error Correction (FEC) Type. 86 */ 87 public static final int OUTER_FEC_OUTER_FEC_NONE = 88 Constants.FrontendDvbcOuterFec.OUTER_FEC_NONE; 89 /** 90 * RS Outer Forward Error Correction (FEC) Type. 91 */ 92 public static final int OUTER_FEC_OUTER_FEC_RS = Constants.FrontendDvbcOuterFec.OUTER_FEC_RS; 93 94 95 /** @hide */ 96 @IntDef(flag = true, 97 prefix = "ANNEX_", 98 value = {ANNEX_UNDEFINED, ANNEX_A, ANNEX_B, ANNEX_C}) 99 @Retention(RetentionPolicy.SOURCE) 100 public @interface Annex {} 101 102 /** 103 * Annex Type undefined. 104 */ 105 public static final int ANNEX_UNDEFINED = Constants.FrontendDvbcAnnex.UNDEFINED; 106 /** 107 * Annex Type A. 108 */ 109 public static final int ANNEX_A = Constants.FrontendDvbcAnnex.A; 110 /** 111 * Annex Type B. 112 */ 113 public static final int ANNEX_B = Constants.FrontendDvbcAnnex.B; 114 /** 115 * Annex Type C. 116 */ 117 public static final int ANNEX_C = Constants.FrontendDvbcAnnex.C; 118 119 120 /** @hide */ 121 @IntDef(prefix = "SPECTRAL_INVERSION_", 122 value = {SPECTRAL_INVERSION_UNDEFINED, SPECTRAL_INVERSION_NORMAL, 123 SPECTRAL_INVERSION_INVERTED}) 124 @Retention(RetentionPolicy.SOURCE) 125 public @interface SpectralInversion {} 126 127 /** 128 * Spectral Inversion Type undefined. 129 */ 130 public static final int SPECTRAL_INVERSION_UNDEFINED = 131 Constants.FrontendDvbcSpectralInversion.UNDEFINED; 132 /** 133 * Normal Spectral Inversion. 134 */ 135 public static final int SPECTRAL_INVERSION_NORMAL = 136 Constants.FrontendDvbcSpectralInversion.NORMAL; 137 /** 138 * Inverted Spectral Inversion. 139 */ 140 public static final int SPECTRAL_INVERSION_INVERTED = 141 Constants.FrontendDvbcSpectralInversion.INVERTED; 142 143 144 private final int mModulation; 145 private final long mInnerFec; 146 private final int mSymbolRate; 147 private final int mOuterFec; 148 private final int mAnnex; 149 private final int mSpectralInversion; 150 DvbcFrontendSettings(int frequency, int modulation, long innerFec, int symbolRate, int outerFec, int annex, int spectralInversion)151 private DvbcFrontendSettings(int frequency, int modulation, long innerFec, int symbolRate, 152 int outerFec, int annex, int spectralInversion) { 153 super(frequency); 154 mModulation = modulation; 155 mInnerFec = innerFec; 156 mSymbolRate = symbolRate; 157 mOuterFec = outerFec; 158 mAnnex = annex; 159 mSpectralInversion = spectralInversion; 160 } 161 162 /** 163 * Gets Modulation. 164 */ 165 @Modulation getModulation()166 public int getModulation() { 167 return mModulation; 168 } 169 /** 170 * Gets Inner Forward Error Correction. 171 */ 172 @InnerFec getInnerFec()173 public long getInnerFec() { 174 return mInnerFec; 175 } 176 /** 177 * Gets Symbol Rate in symbols per second. 178 */ getSymbolRate()179 public int getSymbolRate() { 180 return mSymbolRate; 181 } 182 /** 183 * Gets Outer Forward Error Correction. 184 */ 185 @OuterFec getOuterFec()186 public int getOuterFec() { 187 return mOuterFec; 188 } 189 /** 190 * Gets Annex. 191 */ 192 @Annex getAnnex()193 public int getAnnex() { 194 return mAnnex; 195 } 196 /** 197 * Gets Spectral Inversion. 198 */ 199 @SpectralInversion getSpectralInversion()200 public int getSpectralInversion() { 201 return mSpectralInversion; 202 } 203 204 /** 205 * Creates a builder for {@link DvbcFrontendSettings}. 206 */ 207 @NonNull builder()208 public static Builder builder() { 209 return new Builder(); 210 } 211 212 /** 213 * Builder for {@link DvbcFrontendSettings}. 214 */ 215 public static class Builder { 216 private int mFrequency = 0; 217 private int mModulation = MODULATION_UNDEFINED; 218 private long mInnerFec = FEC_UNDEFINED; 219 private int mSymbolRate = 0; 220 private int mOuterFec = OUTER_FEC_UNDEFINED; 221 private int mAnnex = ANNEX_UNDEFINED; 222 private int mSpectralInversion = SPECTRAL_INVERSION_UNDEFINED; 223 Builder()224 private Builder() { 225 } 226 227 /** 228 * Sets frequency in Hz. 229 * 230 * <p>Default value is 0. 231 */ 232 @NonNull 233 @IntRange(from = 1) setFrequency(int frequency)234 public Builder setFrequency(int frequency) { 235 mFrequency = frequency; 236 return this; 237 } 238 239 /** 240 * Sets Modulation. 241 * 242 * <p>Default value is {@link #MODULATION_UNDEFINED}. 243 */ 244 @NonNull setModulation(@odulation int modulation)245 public Builder setModulation(@Modulation int modulation) { 246 mModulation = modulation; 247 return this; 248 } 249 /** 250 * Sets Inner Forward Error Correction. 251 * 252 * <p>Default value is {@link #FEC_UNDEFINED}. 253 */ 254 @NonNull setInnerFec(@nnerFec long fec)255 public Builder setInnerFec(@InnerFec long fec) { 256 mInnerFec = fec; 257 return this; 258 } 259 /** 260 * Sets Symbol Rate in symbols per second. 261 * 262 * <p>Default value is 0. 263 */ 264 @NonNull setSymbolRate(int symbolRate)265 public Builder setSymbolRate(int symbolRate) { 266 mSymbolRate = symbolRate; 267 return this; 268 } 269 /** 270 * Sets Outer Forward Error Correction. 271 * 272 * <p>Default value is {@link #OUTER_FEC_UNDEFINED}. 273 */ 274 @NonNull setOuterFec(@uterFec int outerFec)275 public Builder setOuterFec(@OuterFec int outerFec) { 276 mOuterFec = outerFec; 277 return this; 278 } 279 /** 280 * Sets Annex. 281 * 282 * <p>Default value is {@link #ANNEX_UNDEFINED}. 283 */ 284 @NonNull setAnnex(@nnex int annex)285 public Builder setAnnex(@Annex int annex) { 286 mAnnex = annex; 287 return this; 288 } 289 /** 290 * Sets Spectral Inversion. 291 * 292 * <p>Default value is {@link #SPECTRAL_INVERSION_UNDEFINED}. 293 */ 294 @NonNull setSpectralInversion(@pectralInversion int spectralInversion)295 public Builder setSpectralInversion(@SpectralInversion int spectralInversion) { 296 mSpectralInversion = spectralInversion; 297 return this; 298 } 299 300 /** 301 * Builds a {@link DvbcFrontendSettings} object. 302 */ 303 @NonNull build()304 public DvbcFrontendSettings build() { 305 return new DvbcFrontendSettings(mFrequency, mModulation, mInnerFec, mSymbolRate, 306 mOuterFec, mAnnex, mSpectralInversion); 307 } 308 } 309 310 @Override getType()311 public int getType() { 312 return FrontendSettings.TYPE_DVBC; 313 } 314 } 315