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 import android.media.tv.tuner.TunerVersionChecker; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 29 /** 30 * Frontend settings for analog tuner. 31 * 32 * @hide 33 */ 34 @SystemApi 35 public class AnalogFrontendSettings extends FrontendSettings { 36 /** @hide */ 37 @IntDef(flag = true, 38 prefix = "SIGNAL_TYPE_", 39 value = {SIGNAL_TYPE_UNDEFINED, SIGNAL_TYPE_AUTO, SIGNAL_TYPE_PAL, SIGNAL_TYPE_PAL_M, 40 SIGNAL_TYPE_PAL_N, SIGNAL_TYPE_PAL_60, SIGNAL_TYPE_NTSC, SIGNAL_TYPE_NTSC_443, 41 SIGNAL_TYPE_SECAM}) 42 @Retention(RetentionPolicy.SOURCE) 43 public @interface SignalType {} 44 45 /** 46 * Undefined analog signal type. 47 */ 48 public static final int SIGNAL_TYPE_UNDEFINED = Constants.FrontendAnalogType.UNDEFINED; 49 /** 50 * AUTO analog signal type. 51 */ 52 public static final int SIGNAL_TYPE_AUTO = Constants.FrontendAnalogType.AUTO; 53 /** 54 * PAL analog signal type. 55 */ 56 public static final int SIGNAL_TYPE_PAL = Constants.FrontendAnalogType.PAL; 57 /** 58 * PAL M analog signal type. 59 */ 60 public static final int SIGNAL_TYPE_PAL_M = Constants.FrontendAnalogType.PAL_M; 61 /** 62 * PAL N analog signal type. 63 */ 64 public static final int SIGNAL_TYPE_PAL_N = Constants.FrontendAnalogType.PAL_N; 65 /** 66 * PAL 60 analog signal type. 67 */ 68 public static final int SIGNAL_TYPE_PAL_60 = Constants.FrontendAnalogType.PAL_60; 69 /** 70 * NTSC analog signal type. 71 */ 72 public static final int SIGNAL_TYPE_NTSC = Constants.FrontendAnalogType.NTSC; 73 /** 74 * NTSC 443 analog signal type. 75 */ 76 public static final int SIGNAL_TYPE_NTSC_443 = Constants.FrontendAnalogType.NTSC_443; 77 /** 78 * SECM analog signal type. 79 */ 80 public static final int SIGNAL_TYPE_SECAM = Constants.FrontendAnalogType.SECAM; 81 82 /** @hide */ 83 @IntDef(flag = true, 84 prefix = "SIF_", 85 value = {SIF_UNDEFINED, SIF_AUTO, SIF_BG, SIF_BG_A2, SIF_BG_NICAM, SIF_I, SIF_DK, 86 SIF_DK1_A2, SIF_DK2_A2, SIF_DK3_A2, SIF_DK_NICAM, SIF_L, SIF_M, SIF_M_BTSC, SIF_M_A2, 87 SIF_M_EIAJ, SIF_I_NICAM, SIF_L_NICAM, SIF_L_PRIME}) 88 @Retention(RetentionPolicy.SOURCE) 89 public @interface SifStandard {} 90 91 /** 92 * Undefined Analog Standard Interchange Format (SIF). 93 */ 94 public static final int SIF_UNDEFINED = Constants.FrontendAnalogSifStandard.UNDEFINED; 95 /** 96 * Audo Analog Standard Interchange Format (SIF). 97 */ 98 public static final int SIF_AUTO = Constants.FrontendAnalogSifStandard.AUTO; 99 /** 100 * BG Analog Standard Interchange Format (SIF). 101 */ 102 public static final int SIF_BG = Constants.FrontendAnalogSifStandard.BG; 103 /** 104 * BG-A2 Analog Standard Interchange Format (SIF). 105 */ 106 public static final int SIF_BG_A2 = Constants.FrontendAnalogSifStandard.BG_A2; 107 /** 108 * BG-NICAM Analog Standard Interchange Format (SIF). 109 */ 110 public static final int SIF_BG_NICAM = Constants.FrontendAnalogSifStandard.BG_NICAM; 111 /** 112 * I Analog Standard Interchange Format (SIF). 113 */ 114 public static final int SIF_I = Constants.FrontendAnalogSifStandard.I; 115 /** 116 * DK Analog Standard Interchange Format (SIF). 117 */ 118 public static final int SIF_DK = Constants.FrontendAnalogSifStandard.DK; 119 /** 120 * DK1 A2 Analog Standard Interchange Format (SIF). 121 */ 122 public static final int SIF_DK1_A2 = Constants.FrontendAnalogSifStandard.DK1_A2; 123 /** 124 * DK2 A2 Analog Standard Interchange Format (SIF). 125 */ 126 public static final int SIF_DK2_A2 = Constants.FrontendAnalogSifStandard.DK2_A2; 127 /** 128 * DK3 A2 Analog Standard Interchange Format (SIF). 129 */ 130 public static final int SIF_DK3_A2 = Constants.FrontendAnalogSifStandard.DK3_A2; 131 /** 132 * DK-NICAM Analog Standard Interchange Format (SIF). 133 */ 134 public static final int SIF_DK_NICAM = Constants.FrontendAnalogSifStandard.DK_NICAM; 135 /** 136 * L Analog Standard Interchange Format (SIF). 137 */ 138 public static final int SIF_L = Constants.FrontendAnalogSifStandard.L; 139 /** 140 * M Analog Standard Interchange Format (SIF). 141 */ 142 public static final int SIF_M = Constants.FrontendAnalogSifStandard.M; 143 /** 144 * M-BTSC Analog Standard Interchange Format (SIF). 145 */ 146 public static final int SIF_M_BTSC = Constants.FrontendAnalogSifStandard.M_BTSC; 147 /** 148 * M-A2 Analog Standard Interchange Format (SIF). 149 */ 150 public static final int SIF_M_A2 = Constants.FrontendAnalogSifStandard.M_A2; 151 /** 152 * M-EIAJ Analog Standard Interchange Format (SIF). 153 */ 154 public static final int SIF_M_EIAJ = Constants.FrontendAnalogSifStandard.M_EIAJ; 155 /** 156 * I-NICAM Analog Standard Interchange Format (SIF). 157 */ 158 public static final int SIF_I_NICAM = Constants.FrontendAnalogSifStandard.I_NICAM; 159 /** 160 * L-NICAM Analog Standard Interchange Format (SIF). 161 */ 162 public static final int SIF_L_NICAM = Constants.FrontendAnalogSifStandard.L_NICAM; 163 /** 164 * L-PRIME Analog Standard Interchange Format (SIF). 165 */ 166 public static final int SIF_L_PRIME = Constants.FrontendAnalogSifStandard.L_PRIME; 167 168 /** @hide */ 169 @IntDef(prefix = "AFT_FLAG_", 170 value = {AFT_FLAG_UNDEFINED, AFT_FLAG_TRUE, AFT_FLAG_FALSE}) 171 @Retention(RetentionPolicy.SOURCE) 172 public @interface AftFlag {} 173 174 /** 175 * Aft flag is not defined. 176 */ 177 public static final int AFT_FLAG_UNDEFINED = 178 android.hardware.tv.tuner.V1_1.Constants.FrontendAnalogAftFlag.UNDEFINED; 179 /** 180 * Aft flag is set true. 181 */ 182 public static final int AFT_FLAG_TRUE = 183 android.hardware.tv.tuner.V1_1.Constants.FrontendAnalogAftFlag.AFT_TRUE; 184 /** 185 * Aft flag is not set. 186 */ 187 public static final int AFT_FLAG_FALSE = 188 android.hardware.tv.tuner.V1_1.Constants.FrontendAnalogAftFlag.AFT_FALSE; 189 190 191 private final int mSignalType; 192 private final int mSifStandard; 193 private final int mAftFlag; 194 195 @Override getType()196 public int getType() { 197 return FrontendSettings.TYPE_ANALOG; 198 } 199 200 201 /** 202 * Gets analog signal type. 203 */ 204 @SignalType getSignalType()205 public int getSignalType() { 206 return mSignalType; 207 } 208 209 /** 210 * Gets Standard Interchange Format (SIF). 211 */ 212 @SifStandard getSifStandard()213 public int getSifStandard() { 214 return mSifStandard; 215 } 216 217 /** 218 * Gets AFT flag. 219 */ 220 @AftFlag getAftFlag()221 public int getAftFlag() { 222 return mAftFlag; 223 } 224 225 /** 226 * Creates a builder for {@link AnalogFrontendSettings}. 227 */ 228 @NonNull builder()229 public static Builder builder() { 230 return new Builder(); 231 } 232 AnalogFrontendSettings(int frequency, int signalType, int sifStandard, int aftFlag)233 private AnalogFrontendSettings(int frequency, int signalType, int sifStandard, int aftFlag) { 234 super(frequency); 235 mSignalType = signalType; 236 mSifStandard = sifStandard; 237 mAftFlag = aftFlag; 238 } 239 240 /** 241 * Builder for {@link AnalogFrontendSettings}. 242 */ 243 public static class Builder { 244 private int mFrequency = 0; 245 private int mSignalType = SIGNAL_TYPE_UNDEFINED; 246 private int mSifStandard = SIF_UNDEFINED; 247 private int mAftFlag = AFT_FLAG_UNDEFINED; 248 Builder()249 private Builder() {} 250 251 /** 252 * Sets frequency in Hz. 253 * 254 * <p>Default value is 0. 255 */ 256 @NonNull 257 @IntRange(from = 1) setFrequency(int frequency)258 public Builder setFrequency(int frequency) { 259 mFrequency = frequency; 260 return this; 261 } 262 263 /** 264 * Set Aft flag. 265 * 266 * <p>This API is only supported by Tuner HAL 1.1 or higher. Unsupported version would cause 267 * no-op. Use {@link TunerVersionChecker#getTunerVersion()} to check the version. 268 * 269 * @param aftFlag the value to set the aft flag. The default value is 270 * {@link #AFT_FLAG_UNDEFINED}. 271 */ 272 @NonNull setAftFlag(@ftFlag int aftFlag)273 public Builder setAftFlag(@AftFlag int aftFlag) { 274 if (TunerVersionChecker.checkHigherOrEqualVersionTo( 275 TunerVersionChecker.TUNER_VERSION_1_1, "setAftFlag")) { 276 mAftFlag = aftFlag; 277 } 278 return this; 279 } 280 281 /** 282 * Sets analog signal type. 283 * 284 * <p>Default value is {@link #SIGNAL_TYPE_UNDEFINED}. 285 */ 286 @NonNull setSignalType(@ignalType int signalType)287 public Builder setSignalType(@SignalType int signalType) { 288 mSignalType = signalType; 289 return this; 290 } 291 292 /** 293 * Sets Standard Interchange Format (SIF). 294 * 295 * <p>Default value is {@link #SIF_UNDEFINED}. 296 */ 297 @NonNull setSifStandard(@ifStandard int sifStandard)298 public Builder setSifStandard(@SifStandard int sifStandard) { 299 mSifStandard = sifStandard; 300 return this; 301 } 302 303 /** 304 * Builds a {@link AnalogFrontendSettings} object. 305 */ 306 @NonNull build()307 public AnalogFrontendSettings build() { 308 return new AnalogFrontendSettings(mFrequency, mSignalType, mSifStandard, mAftFlag); 309 } 310 } 311 } 312