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.FrontendAtscModulation; 24 25 import java.lang.annotation.Retention; 26 import java.lang.annotation.RetentionPolicy; 27 28 /** 29 * Frontend settings for ATSC. 30 * 31 * @hide 32 */ 33 @SystemApi 34 public class AtscFrontendSettings extends FrontendSettings { 35 36 /** @hide */ 37 @IntDef(prefix = "MODULATION_", 38 value = {MODULATION_UNDEFINED, MODULATION_AUTO, MODULATION_MOD_8VSB, 39 MODULATION_MOD_16VSB}) 40 @Retention(RetentionPolicy.SOURCE) 41 public @interface Modulation {} 42 43 /** 44 * Modulation undefined. 45 */ 46 public static final int MODULATION_UNDEFINED = FrontendAtscModulation.UNDEFINED; 47 /** 48 * Hardware is able to detect and set modulation automatically 49 */ 50 public static final int MODULATION_AUTO = FrontendAtscModulation.AUTO; 51 /** 52 * 8VSB Modulation. 53 */ 54 public static final int MODULATION_MOD_8VSB = FrontendAtscModulation.MOD_8VSB; 55 /** 56 * 16VSB Modulation. 57 */ 58 public static final int MODULATION_MOD_16VSB = FrontendAtscModulation.MOD_16VSB; 59 60 61 private final int mModulation; 62 AtscFrontendSettings(long frequency, int modulation)63 private AtscFrontendSettings(long frequency, int modulation) { 64 super(frequency); 65 mModulation = modulation; 66 } 67 68 /** 69 * Gets Modulation. 70 */ 71 @Modulation getModulation()72 public int getModulation() { 73 return mModulation; 74 } 75 76 /** 77 * Creates a builder for {@link AtscFrontendSettings}. 78 */ 79 @NonNull builder()80 public static Builder builder() { 81 return new Builder(); 82 } 83 84 /** 85 * Builder for {@link AtscFrontendSettings}. 86 */ 87 public static class Builder { 88 private long mFrequency = 0; 89 private int mModulation = MODULATION_UNDEFINED; 90 Builder()91 private Builder() { 92 } 93 94 /** 95 * Sets frequency in Hz. 96 * 97 * <p>Default value is 0. 98 * @deprecated Use {@link #setFrequencyLong(long)} 99 */ 100 @NonNull 101 @IntRange(from = 1) 102 @Deprecated setFrequency(int frequency)103 public Builder setFrequency(int frequency) { 104 return setFrequencyLong((long) frequency); 105 } 106 107 /** 108 * Sets frequency in Hz. 109 * 110 * <p>Default value is 0. 111 */ 112 @NonNull 113 @IntRange(from = 1) setFrequencyLong(long frequency)114 public Builder setFrequencyLong(long frequency) { 115 mFrequency = frequency; 116 return this; 117 } 118 119 /** 120 * Sets Modulation. 121 * 122 * <p>Default value is {@link #MODULATION_UNDEFINED}. 123 */ 124 @NonNull setModulation(@odulation int modulation)125 public Builder setModulation(@Modulation int modulation) { 126 mModulation = modulation; 127 return this; 128 } 129 130 /** 131 * Builds a {@link AtscFrontendSettings} object. 132 */ 133 @NonNull build()134 public AtscFrontendSettings build() { 135 return new AtscFrontendSettings(mFrequency, mModulation); 136 } 137 } 138 139 @Override getType()140 public int getType() { 141 return FrontendSettings.TYPE_ATSC; 142 } 143 } 144