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