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.FrontendIsdbs3Coderate; 24 import android.hardware.tv.tuner.FrontendIsdbs3Modulation; 25 import android.hardware.tv.tuner.FrontendIsdbs3Rolloff; 26 import android.media.tv.tuner.Tuner; 27 28 import java.lang.annotation.Retention; 29 import java.lang.annotation.RetentionPolicy; 30 31 /** 32 * Frontend settings for ISDBS-3. 33 * 34 * @hide 35 */ 36 @SystemApi 37 public class Isdbs3FrontendSettings extends FrontendSettings { 38 /** @hide */ 39 @IntDef(prefix = "MODULATION_", 40 value = {MODULATION_UNDEFINED, MODULATION_AUTO, MODULATION_MOD_BPSK, 41 MODULATION_MOD_QPSK, MODULATION_MOD_8PSK, MODULATION_MOD_16APSK, 42 MODULATION_MOD_32APSK}) 43 @Retention(RetentionPolicy.SOURCE) 44 public @interface Modulation {} 45 46 /** 47 * Modulation undefined. 48 */ 49 public static final int MODULATION_UNDEFINED = FrontendIsdbs3Modulation.UNDEFINED; 50 /** 51 * Hardware is able to detect and set modulation automatically. 52 */ 53 public static final int MODULATION_AUTO = FrontendIsdbs3Modulation.AUTO; 54 /** 55 * BPSK Modulation. 56 */ 57 public static final int MODULATION_MOD_BPSK = FrontendIsdbs3Modulation.MOD_BPSK; 58 /** 59 * QPSK Modulation. 60 */ 61 public static final int MODULATION_MOD_QPSK = FrontendIsdbs3Modulation.MOD_QPSK; 62 /** 63 * 8PSK Modulation. 64 */ 65 public static final int MODULATION_MOD_8PSK = FrontendIsdbs3Modulation.MOD_8PSK; 66 /** 67 * 16APSK Modulation. 68 */ 69 public static final int MODULATION_MOD_16APSK = FrontendIsdbs3Modulation.MOD_16APSK; 70 /** 71 * 32APSK Modulation. 72 */ 73 public static final int MODULATION_MOD_32APSK = FrontendIsdbs3Modulation.MOD_32APSK; 74 75 /** @hide */ 76 @Retention(RetentionPolicy.SOURCE) 77 @IntDef(prefix = "CODERATE_", 78 value = {CODERATE_UNDEFINED, CODERATE_AUTO, CODERATE_1_3, CODERATE_2_5, CODERATE_1_2, 79 CODERATE_3_5, CODERATE_2_3, CODERATE_3_4, CODERATE_7_9, CODERATE_4_5, 80 CODERATE_5_6, CODERATE_7_8, CODERATE_9_10}) 81 public @interface CodeRate {} 82 83 /** 84 * Code rate undefined. 85 */ 86 public static final int CODERATE_UNDEFINED = FrontendIsdbs3Coderate.UNDEFINED; 87 /** 88 * Hardware is able to detect and set code rate automatically. 89 */ 90 public static final int CODERATE_AUTO = FrontendIsdbs3Coderate.AUTO; 91 /** 92 * 1/3 code rate. 93 */ 94 public static final int CODERATE_1_3 = FrontendIsdbs3Coderate.CODERATE_1_3; 95 /** 96 * 2/5 code rate. 97 */ 98 public static final int CODERATE_2_5 = FrontendIsdbs3Coderate.CODERATE_2_5; 99 /** 100 * 1/2 code rate. 101 */ 102 public static final int CODERATE_1_2 = FrontendIsdbs3Coderate.CODERATE_1_2; 103 /** 104 * 3/5 code rate. 105 */ 106 public static final int CODERATE_3_5 = FrontendIsdbs3Coderate.CODERATE_3_5; 107 /** 108 * 2/3 code rate. 109 */ 110 public static final int CODERATE_2_3 = FrontendIsdbs3Coderate.CODERATE_2_3; 111 /** 112 * 3/4 code rate. 113 */ 114 public static final int CODERATE_3_4 = FrontendIsdbs3Coderate.CODERATE_3_4; 115 /** 116 * 7/9 code rate. 117 */ 118 public static final int CODERATE_7_9 = FrontendIsdbs3Coderate.CODERATE_7_9; 119 /** 120 * 4/5 code rate. 121 */ 122 public static final int CODERATE_4_5 = FrontendIsdbs3Coderate.CODERATE_4_5; 123 /** 124 * 5/6 code rate. 125 */ 126 public static final int CODERATE_5_6 = FrontendIsdbs3Coderate.CODERATE_5_6; 127 /** 128 * 7/8 code rate. 129 */ 130 public static final int CODERATE_7_8 = FrontendIsdbs3Coderate.CODERATE_7_8; 131 /** 132 * 9/10 code rate. 133 */ 134 public static final int CODERATE_9_10 = FrontendIsdbs3Coderate.CODERATE_9_10; 135 136 /** @hide */ 137 @Retention(RetentionPolicy.SOURCE) 138 @IntDef(prefix = "ROLLOFF_", 139 value = {ROLLOFF_UNDEFINED, ROLLOFF_0_03}) 140 public @interface Rolloff {} 141 142 /** 143 * Rolloff type undefined. 144 */ 145 public static final int ROLLOFF_UNDEFINED = FrontendIsdbs3Rolloff.UNDEFINED; 146 /** 147 * 0,03 Rolloff. 148 */ 149 public static final int ROLLOFF_0_03 = FrontendIsdbs3Rolloff.ROLLOFF_0_03; 150 151 152 private final int mStreamId; 153 private final int mStreamIdType; 154 private final int mModulation; 155 private final int mCodeRate; 156 private final int mSymbolRate; 157 private final int mRolloff; 158 Isdbs3FrontendSettings(long frequency, int streamId, int streamIdType, int modulation, int codeRate, int symbolRate, int rolloff)159 private Isdbs3FrontendSettings(long frequency, int streamId, int streamIdType, int modulation, 160 int codeRate, int symbolRate, int rolloff) { 161 super(frequency); 162 mStreamId = streamId; 163 mStreamIdType = streamIdType; 164 mModulation = modulation; 165 mCodeRate = codeRate; 166 mSymbolRate = symbolRate; 167 mRolloff = rolloff; 168 } 169 170 /** 171 * Gets Stream ID. 172 */ getStreamId()173 public int getStreamId() { 174 return mStreamId; 175 } 176 /** 177 * Gets Stream ID Type. 178 */ 179 @IsdbsFrontendSettings.StreamIdType getStreamIdType()180 public int getStreamIdType() { 181 return mStreamIdType; 182 } 183 /** 184 * Gets Modulation. 185 */ 186 @Modulation getModulation()187 public int getModulation() { 188 return mModulation; 189 } 190 /** 191 * Gets Code rate. 192 */ 193 @CodeRate getCodeRate()194 public int getCodeRate() { 195 return mCodeRate; 196 } 197 /** 198 * Gets Symbol Rate in symbols per second. 199 */ getSymbolRate()200 public int getSymbolRate() { 201 return mSymbolRate; 202 } 203 /** 204 * Gets Roll off type. 205 */ 206 @Rolloff getRolloff()207 public int getRolloff() { 208 return mRolloff; 209 } 210 211 /** 212 * Creates a builder for {@link Isdbs3FrontendSettings}. 213 */ 214 @NonNull builder()215 public static Builder builder() { 216 return new Builder(); 217 } 218 219 /** 220 * Builder for {@link Isdbs3FrontendSettings}. 221 */ 222 public static class Builder { 223 private long mFrequency = 0; 224 private int mStreamId = Tuner.INVALID_STREAM_ID; 225 private int mStreamIdType = IsdbsFrontendSettings.STREAM_ID_TYPE_ID; 226 private int mModulation = MODULATION_UNDEFINED; 227 private int mCodeRate = CODERATE_UNDEFINED; 228 private int mSymbolRate = 0; 229 private int mRolloff = ROLLOFF_UNDEFINED; 230 Builder()231 private Builder() { 232 } 233 234 /** 235 * Sets frequency in Hz. 236 * 237 * <p>Default value is 0. 238 * @deprecated Use {@link #setFrequencyLong(long)} 239 */ 240 @NonNull 241 @IntRange(from = 1) 242 @Deprecated setFrequency(int frequency)243 public Builder setFrequency(int frequency) { 244 return setFrequencyLong((long) frequency); 245 } 246 247 /** 248 * Sets frequency in Hz. 249 * 250 * <p>Default value is 0. 251 */ 252 @NonNull 253 @IntRange(from = 1) setFrequencyLong(long frequency)254 public Builder setFrequencyLong(long frequency) { 255 mFrequency = frequency; 256 return this; 257 } 258 259 /** 260 * Sets Stream ID. 261 * 262 * <p>Default value is {@link Tuner#INVALID_STREAM_ID}. 263 */ 264 @NonNull setStreamId(int streamId)265 public Builder setStreamId(int streamId) { 266 mStreamId = streamId; 267 return this; 268 } 269 /** 270 * Sets StreamIdType. 271 * 272 * <p>Default value is {@link IsdbsFrontendSettings#STREAM_ID_TYPE_ID}. 273 */ 274 @NonNull setStreamIdType(@sdbsFrontendSettings.StreamIdType int streamIdType)275 public Builder setStreamIdType(@IsdbsFrontendSettings.StreamIdType int streamIdType) { 276 mStreamIdType = streamIdType; 277 return this; 278 } 279 /** 280 * Sets Modulation. 281 * 282 * <p>Default value is {@link #MODULATION_UNDEFINED}. 283 */ 284 @NonNull setModulation(@odulation int modulation)285 public Builder setModulation(@Modulation int modulation) { 286 mModulation = modulation; 287 return this; 288 } 289 /** 290 * Sets Code rate. 291 * 292 * <p>Default value is {@link #CODERATE_UNDEFINED}. 293 */ 294 @NonNull setCodeRate(@odeRate int codeRate)295 public Builder setCodeRate(@CodeRate int codeRate) { 296 mCodeRate = codeRate; 297 return this; 298 } 299 /** 300 * Sets Symbol Rate in symbols per second. 301 * 302 * <p>Default value is 0. 303 */ 304 @NonNull setSymbolRate(int symbolRate)305 public Builder setSymbolRate(int symbolRate) { 306 mSymbolRate = symbolRate; 307 return this; 308 } 309 /** 310 * Sets Roll off type. 311 * 312 * <p>Default value is {@link #ROLLOFF_UNDEFINED}. 313 */ 314 @NonNull setRolloff(@olloff int rolloff)315 public Builder setRolloff(@Rolloff int rolloff) { 316 mRolloff = rolloff; 317 return this; 318 } 319 320 /** 321 * Builds a {@link Isdbs3FrontendSettings} object. 322 */ 323 @NonNull build()324 public Isdbs3FrontendSettings build() { 325 return new Isdbs3FrontendSettings(mFrequency, mStreamId, mStreamIdType, mModulation, 326 mCodeRate, mSymbolRate, mRolloff); 327 } 328 } 329 330 @Override getType()331 public int getType() { 332 return FrontendSettings.TYPE_ISDBS3; 333 } 334 } 335