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.Tuner; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 29 /** 30 * Frontend settings for ISDBS-3. 31 * 32 * @hide 33 */ 34 @SystemApi 35 public class Isdbs3FrontendSettings extends FrontendSettings { 36 /** @hide */ 37 @IntDef(flag = true, 38 prefix = "MODULATION_", 39 value = {MODULATION_UNDEFINED, MODULATION_AUTO, MODULATION_MOD_BPSK, 40 MODULATION_MOD_QPSK, MODULATION_MOD_8PSK, MODULATION_MOD_16APSK, 41 MODULATION_MOD_32APSK}) 42 @Retention(RetentionPolicy.SOURCE) 43 public @interface Modulation {} 44 45 /** 46 * Modulation undefined. 47 */ 48 public static final int MODULATION_UNDEFINED = Constants.FrontendIsdbs3Modulation.UNDEFINED; 49 /** 50 * Hardware is able to detect and set modulation automatically. 51 */ 52 public static final int MODULATION_AUTO = Constants.FrontendIsdbs3Modulation.AUTO; 53 /** 54 * BPSK Modulation. 55 */ 56 public static final int MODULATION_MOD_BPSK = Constants.FrontendIsdbs3Modulation.MOD_BPSK; 57 /** 58 * QPSK Modulation. 59 */ 60 public static final int MODULATION_MOD_QPSK = Constants.FrontendIsdbs3Modulation.MOD_QPSK; 61 /** 62 * 8PSK Modulation. 63 */ 64 public static final int MODULATION_MOD_8PSK = Constants.FrontendIsdbs3Modulation.MOD_8PSK; 65 /** 66 * 16APSK Modulation. 67 */ 68 public static final int MODULATION_MOD_16APSK = Constants.FrontendIsdbs3Modulation.MOD_16APSK; 69 /** 70 * 32APSK Modulation. 71 */ 72 public static final int MODULATION_MOD_32APSK = Constants.FrontendIsdbs3Modulation.MOD_32APSK; 73 74 /** @hide */ 75 @Retention(RetentionPolicy.SOURCE) 76 @IntDef(flag = true, 77 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 = Constants.FrontendIsdbs3Coderate.UNDEFINED; 87 /** 88 * Hardware is able to detect and set code rate automatically. 89 */ 90 public static final int CODERATE_AUTO = Constants.FrontendIsdbs3Coderate.AUTO; 91 /** 92 * 1/3 code rate. 93 */ 94 public static final int CODERATE_1_3 = Constants.FrontendIsdbs3Coderate.CODERATE_1_3; 95 /** 96 * 2/5 code rate. 97 */ 98 public static final int CODERATE_2_5 = Constants.FrontendIsdbs3Coderate.CODERATE_2_5; 99 /** 100 * 1/2 code rate. 101 */ 102 public static final int CODERATE_1_2 = Constants.FrontendIsdbs3Coderate.CODERATE_1_2; 103 /** 104 * 3/5 code rate. 105 */ 106 public static final int CODERATE_3_5 = Constants.FrontendIsdbs3Coderate.CODERATE_3_5; 107 /** 108 * 2/3 code rate. 109 */ 110 public static final int CODERATE_2_3 = Constants.FrontendIsdbs3Coderate.CODERATE_2_3; 111 /** 112 * 3/4 code rate. 113 */ 114 public static final int CODERATE_3_4 = Constants.FrontendIsdbs3Coderate.CODERATE_3_4; 115 /** 116 * 7/9 code rate. 117 */ 118 public static final int CODERATE_7_9 = Constants.FrontendIsdbs3Coderate.CODERATE_7_9; 119 /** 120 * 4/5 code rate. 121 */ 122 public static final int CODERATE_4_5 = Constants.FrontendIsdbs3Coderate.CODERATE_4_5; 123 /** 124 * 5/6 code rate. 125 */ 126 public static final int CODERATE_5_6 = Constants.FrontendIsdbs3Coderate.CODERATE_5_6; 127 /** 128 * 7/8 code rate. 129 */ 130 public static final int CODERATE_7_8 = Constants.FrontendIsdbs3Coderate.CODERATE_7_8; 131 /** 132 * 9/10 code rate. 133 */ 134 public static final int CODERATE_9_10 = Constants.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 = Constants.FrontendIsdbs3Rolloff.UNDEFINED; 146 /** 147 * 0,03 Rolloff. 148 */ 149 public static final int ROLLOFF_0_03 = Constants.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(int frequency, int streamId, int streamIdType, int modulation, int codeRate, int symbolRate, int rolloff)159 private Isdbs3FrontendSettings(int 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 int 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 */ 239 @NonNull 240 @IntRange(from = 1) setFrequency(int frequency)241 public Builder setFrequency(int frequency) { 242 mFrequency = frequency; 243 return this; 244 } 245 246 /** 247 * Sets Stream ID. 248 * 249 * <p>Default value is {@link Tuner#INVALID_STREAM_ID}. 250 */ 251 @NonNull setStreamId(int streamId)252 public Builder setStreamId(int streamId) { 253 mStreamId = streamId; 254 return this; 255 } 256 /** 257 * Sets StreamIdType. 258 * 259 * <p>Default value is {@link IsdbsFrontendSettings#STREAM_ID_TYPE_ID}. 260 */ 261 @NonNull setStreamIdType(@sdbsFrontendSettings.StreamIdType int streamIdType)262 public Builder setStreamIdType(@IsdbsFrontendSettings.StreamIdType int streamIdType) { 263 mStreamIdType = streamIdType; 264 return this; 265 } 266 /** 267 * Sets Modulation. 268 * 269 * <p>Default value is {@link #MODULATION_UNDEFINED}. 270 */ 271 @NonNull setModulation(@odulation int modulation)272 public Builder setModulation(@Modulation int modulation) { 273 mModulation = modulation; 274 return this; 275 } 276 /** 277 * Sets Code rate. 278 * 279 * <p>Default value is {@link #CODERATE_UNDEFINED}. 280 */ 281 @NonNull setCodeRate(@odeRate int codeRate)282 public Builder setCodeRate(@CodeRate int codeRate) { 283 mCodeRate = codeRate; 284 return this; 285 } 286 /** 287 * Sets Symbol Rate in symbols per second. 288 * 289 * <p>Default value is 0. 290 */ 291 @NonNull setSymbolRate(int symbolRate)292 public Builder setSymbolRate(int symbolRate) { 293 mSymbolRate = symbolRate; 294 return this; 295 } 296 /** 297 * Sets Roll off type. 298 * 299 * <p>Default value is {@link #ROLLOFF_UNDEFINED}. 300 */ 301 @NonNull setRolloff(@olloff int rolloff)302 public Builder setRolloff(@Rolloff int rolloff) { 303 mRolloff = rolloff; 304 return this; 305 } 306 307 /** 308 * Builds a {@link Isdbs3FrontendSettings} object. 309 */ 310 @NonNull build()311 public Isdbs3FrontendSettings build() { 312 return new Isdbs3FrontendSettings(mFrequency, mStreamId, mStreamIdType, mModulation, 313 mCodeRate, mSymbolRate, mRolloff); 314 } 315 } 316 317 @Override getType()318 public int getType() { 319 return FrontendSettings.TYPE_ISDBS3; 320 } 321 } 322