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.frontend.DvbtFrontendSettings.CodeRate; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 29 /** 30 * Frontend settings for ISDBT. 31 * 32 * @hide 33 */ 34 @SystemApi 35 public class IsdbtFrontendSettings extends FrontendSettings { 36 /** @hide */ 37 @IntDef(flag = true, 38 prefix = "MODULATION_", 39 value = {MODULATION_UNDEFINED, MODULATION_AUTO, MODULATION_MOD_DQPSK, 40 MODULATION_MOD_QPSK, MODULATION_MOD_16QAM, MODULATION_MOD_64QAM}) 41 @Retention(RetentionPolicy.SOURCE) 42 public @interface Modulation {} 43 44 /** 45 * Modulation undefined. 46 */ 47 public static final int MODULATION_UNDEFINED = Constants.FrontendIsdbtModulation.UNDEFINED; 48 /** 49 * Hardware is able to detect and set modulation automatically 50 */ 51 public static final int MODULATION_AUTO = Constants.FrontendIsdbtModulation.AUTO; 52 /** 53 * DQPSK Modulation. 54 */ 55 public static final int MODULATION_MOD_DQPSK = Constants.FrontendIsdbtModulation.MOD_DQPSK; 56 /** 57 * QPSK Modulation. 58 */ 59 public static final int MODULATION_MOD_QPSK = Constants.FrontendIsdbtModulation.MOD_QPSK; 60 /** 61 * 16QAM Modulation. 62 */ 63 public static final int MODULATION_MOD_16QAM = Constants.FrontendIsdbtModulation.MOD_16QAM; 64 /** 65 * 64QAM Modulation. 66 */ 67 public static final int MODULATION_MOD_64QAM = Constants.FrontendIsdbtModulation.MOD_64QAM; 68 69 70 /** @hide */ 71 @IntDef(flag = true, 72 prefix = "MODE_", 73 value = {MODE_UNDEFINED, MODE_AUTO, MODE_1, MODE_2, MODE_3}) 74 @Retention(RetentionPolicy.SOURCE) 75 public @interface Mode {} 76 77 /** 78 * Mode undefined. 79 */ 80 public static final int MODE_UNDEFINED = Constants.FrontendIsdbtMode.UNDEFINED; 81 /** 82 * Hardware is able to detect and set Mode automatically. 83 */ 84 public static final int MODE_AUTO = Constants.FrontendIsdbtMode.AUTO; 85 /** 86 * Mode 1 87 */ 88 public static final int MODE_1 = Constants.FrontendIsdbtMode.MODE_1; 89 /** 90 * Mode 2 91 */ 92 public static final int MODE_2 = Constants.FrontendIsdbtMode.MODE_2; 93 /** 94 * Mode 3 95 */ 96 public static final int MODE_3 = Constants.FrontendIsdbtMode.MODE_3; 97 98 99 /** @hide */ 100 @IntDef(flag = true, 101 prefix = "BANDWIDTH_", 102 value = {BANDWIDTH_UNDEFINED, BANDWIDTH_AUTO, BANDWIDTH_8MHZ, BANDWIDTH_7MHZ, 103 BANDWIDTH_6MHZ}) 104 @Retention(RetentionPolicy.SOURCE) 105 public @interface Bandwidth {} 106 107 /** 108 * Bandwidth undefined. 109 */ 110 public static final int BANDWIDTH_UNDEFINED = Constants.FrontendIsdbtBandwidth.UNDEFINED; 111 /** 112 * Hardware is able to detect and set Bandwidth automatically. 113 */ 114 public static final int BANDWIDTH_AUTO = Constants.FrontendIsdbtBandwidth.AUTO; 115 /** 116 * 8 MHz bandwidth. 117 */ 118 public static final int BANDWIDTH_8MHZ = Constants.FrontendIsdbtBandwidth.BANDWIDTH_8MHZ; 119 /** 120 * 7 MHz bandwidth. 121 */ 122 public static final int BANDWIDTH_7MHZ = Constants.FrontendIsdbtBandwidth.BANDWIDTH_7MHZ; 123 /** 124 * 6 MHz bandwidth. 125 */ 126 public static final int BANDWIDTH_6MHZ = Constants.FrontendIsdbtBandwidth.BANDWIDTH_6MHZ; 127 128 private final int mModulation; 129 private final int mBandwidth; 130 private final int mMode; 131 private final int mCodeRate; 132 private final int mGuardInterval; 133 private final int mServiceAreaId; 134 IsdbtFrontendSettings(int frequency, int modulation, int bandwidth, int mode, int codeRate, int guardInterval, int serviceAreaId)135 private IsdbtFrontendSettings(int frequency, int modulation, int bandwidth, int mode, 136 int codeRate, int guardInterval, int serviceAreaId) { 137 super(frequency); 138 mModulation = modulation; 139 mBandwidth = bandwidth; 140 mMode = mode; 141 mCodeRate = codeRate; 142 mGuardInterval = guardInterval; 143 mServiceAreaId = serviceAreaId; 144 } 145 146 /** 147 * Gets Modulation. 148 */ 149 @Modulation getModulation()150 public int getModulation() { 151 return mModulation; 152 } 153 /** 154 * Gets Bandwidth. 155 */ 156 @Bandwidth getBandwidth()157 public int getBandwidth() { 158 return mBandwidth; 159 } 160 /** 161 * Gets ISDBT mode. 162 */ 163 @Mode getMode()164 public int getMode() { 165 return mMode; 166 } 167 /** 168 * Gets Code rate. 169 */ 170 @CodeRate getCodeRate()171 public int getCodeRate() { 172 return mCodeRate; 173 } 174 /** 175 * Gets Guard Interval. 176 */ 177 @DvbtFrontendSettings.GuardInterval getGuardInterval()178 public int getGuardInterval() { 179 return mGuardInterval; 180 } 181 /** 182 * Gets Service Area ID. 183 */ getServiceAreaId()184 public int getServiceAreaId() { 185 return mServiceAreaId; 186 } 187 188 /** 189 * Creates a builder for {@link IsdbtFrontendSettings}. 190 */ 191 @NonNull builder()192 public static Builder builder() { 193 return new Builder(); 194 } 195 196 /** 197 * Builder for {@link IsdbtFrontendSettings}. 198 */ 199 public static class Builder { 200 private int mFrequency = 0; 201 private int mModulation = MODULATION_UNDEFINED; 202 private int mBandwidth = BANDWIDTH_UNDEFINED; 203 private int mMode = MODE_UNDEFINED; 204 private int mCodeRate = DvbtFrontendSettings.CODERATE_UNDEFINED; 205 private int mGuardInterval = DvbtFrontendSettings.GUARD_INTERVAL_UNDEFINED; 206 private int mServiceAreaId = 0; 207 Builder()208 private Builder() { 209 } 210 211 /** 212 * Sets frequency in Hz. 213 * 214 * <p>Default value is 0. 215 */ 216 @NonNull 217 @IntRange(from = 1) setFrequency(int frequency)218 public Builder setFrequency(int frequency) { 219 mFrequency = frequency; 220 return this; 221 } 222 223 /** 224 * Sets Modulation. 225 * 226 * <p>Default value is {@link #MODULATION_UNDEFINED}. 227 */ 228 @NonNull setModulation(@odulation int modulation)229 public Builder setModulation(@Modulation int modulation) { 230 mModulation = modulation; 231 return this; 232 } 233 /** 234 * Sets Bandwidth. 235 * 236 * <p>Default value is {@link #BANDWIDTH_UNDEFINED}. 237 */ 238 @NonNull setBandwidth(@andwidth int bandwidth)239 public Builder setBandwidth(@Bandwidth int bandwidth) { 240 mBandwidth = bandwidth; 241 return this; 242 } 243 /** 244 * Sets ISDBT mode. 245 * 246 * <p>Default value is {@link #MODE_UNDEFINED}. 247 */ 248 @NonNull setMode(@ode int mode)249 public Builder setMode(@Mode int mode) { 250 mMode = mode; 251 return this; 252 } 253 /** 254 * Sets Code rate. 255 * 256 * <p>Default value is {@link DvbtFrontendSettings#CODERATE_UNDEFINED}. 257 */ 258 @NonNull setCodeRate(@vbtFrontendSettings.CodeRate int codeRate)259 public Builder setCodeRate(@DvbtFrontendSettings.CodeRate int codeRate) { 260 mCodeRate = codeRate; 261 return this; 262 } 263 /** 264 * Sets Guard Interval. 265 * 266 * <p>Default value is {@link DvbtFrontendSettings#GUARD_INTERVAL_UNDEFINED}. 267 */ 268 @NonNull setGuardInterval(@vbtFrontendSettings.GuardInterval int guardInterval)269 public Builder setGuardInterval(@DvbtFrontendSettings.GuardInterval int guardInterval) { 270 mGuardInterval = guardInterval; 271 return this; 272 } 273 /** 274 * Sets Service Area ID. 275 * 276 * <p>Default value is 0. 277 */ 278 @NonNull setServiceAreaId(int serviceAreaId)279 public Builder setServiceAreaId(int serviceAreaId) { 280 mServiceAreaId = serviceAreaId; 281 return this; 282 } 283 284 /** 285 * Builds a {@link IsdbtFrontendSettings} object. 286 */ 287 @NonNull build()288 public IsdbtFrontendSettings build() { 289 return new IsdbtFrontendSettings(mFrequency, mModulation, mBandwidth, mMode, mCodeRate, 290 mGuardInterval, mServiceAreaId); 291 } 292 } 293 294 @Override getType()295 public int getType() { 296 return FrontendSettings.TYPE_ISDBT; 297 } 298 } 299