• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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.SuppressLint;
23 import android.annotation.SystemApi;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * Frontend settings for DTMB.
30  *
31  * <p>DTMB Frontend is only supported in Tuner HAL 1.1 or higher. Use {@link
32  * android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the version information.
33  *
34  * @hide
35  */
36 @SystemApi
37 public final class DtmbFrontendSettings extends FrontendSettings {
38 
39     /** @hide */
40     @IntDef(flag = true,
41             prefix = "BANDWIDTH_",
42             value = {BANDWIDTH_UNDEFINED, BANDWIDTH_AUTO, BANDWIDTH_6MHZ, BANDWIDTH_8MHZ})
43     @Retention(RetentionPolicy.SOURCE)
44     public @interface Bandwidth {}
45 
46     /**
47      * Bandwidth not defined.
48      */
49     public static final int BANDWIDTH_UNDEFINED =
50             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbBandwidth.UNDEFINED;
51     /**
52      * Hardware is able to detect and set bandwidth automatically
53      */
54     public static final int BANDWIDTH_AUTO =
55             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbBandwidth.AUTO;
56     /**
57      * 6 MHz bandwidth.
58      */
59     public static final int BANDWIDTH_6MHZ =
60             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbBandwidth.BANDWIDTH_6MHZ;
61     /**
62      * 8 MHz bandwidth.
63      */
64     public static final int BANDWIDTH_8MHZ =
65             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbBandwidth.BANDWIDTH_8MHZ;
66 
67 
68     /** @hide */
69     @IntDef(flag = true,
70             prefix = "TIME_INTERLEAVE_MODE_",
71             value = {TIME_INTERLEAVE_MODE_UNDEFINED, TIME_INTERLEAVE_MODE_AUTO,
72                     TIME_INTERLEAVE_MODE_TIMER_INT_240, TIME_INTERLEAVE_MODE_TIMER_INT_720})
73     @Retention(RetentionPolicy.SOURCE)
74     public @interface TimeInterleaveMode {}
75 
76     /**
77      * Time Interleave Mode undefined.
78      */
79     public static final int TIME_INTERLEAVE_MODE_UNDEFINED =
80             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTimeInterleaveMode.UNDEFINED;
81     /**
82      * Hardware is able to detect and set time interleave mode automatically
83      */
84     public static final int TIME_INTERLEAVE_MODE_AUTO =
85             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTimeInterleaveMode.AUTO;
86     /**
87      * Time Interleave Mode timer int 240.
88      */
89     public static final int TIME_INTERLEAVE_MODE_TIMER_INT_240 =
90             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTimeInterleaveMode.TIMER_INT_240;
91     /**
92      * Time Interleave Mode timer int 720.
93      */
94     public static final int TIME_INTERLEAVE_MODE_TIMER_INT_720 =
95             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTimeInterleaveMode.TIMER_INT_720;
96 
97 
98     /** @hide */
99     @IntDef(flag = true,
100             prefix = "GUARD_INTERVAL_",
101             value = {GUARD_INTERVAL_UNDEFINED, GUARD_INTERVAL_AUTO,
102             GUARD_INTERVAL_PN_420_VARIOUS, GUARD_INTERVAL_PN_595_CONST,
103             GUARD_INTERVAL_PN_945_VARIOUS, GUARD_INTERVAL_PN_420_CONST,
104             GUARD_INTERVAL_PN_945_CONST, GUARD_INTERVAL_PN_RESERVED})
105     @Retention(RetentionPolicy.SOURCE)
106     public @interface GuardInterval {}
107 
108     /**
109      * Guard Interval undefined.
110      */
111     public static final int GUARD_INTERVAL_UNDEFINED =
112             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.UNDEFINED;
113     /**
114      * Hardware is able to detect and set Guard Interval automatically.
115      */
116     public static final int GUARD_INTERVAL_AUTO =
117             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.AUTO;
118     /**
119      * PN_420_VARIOUS Guard Interval.
120      */
121     public static final int GUARD_INTERVAL_PN_420_VARIOUS =
122             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.PN_420_VARIOUS;
123     /**
124      * PN_595_CONST Guard Interval.
125      */
126     public static final int GUARD_INTERVAL_PN_595_CONST =
127             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.PN_595_CONST;
128     /**
129      * PN_945_VARIOUS Guard Interval.
130      */
131     public static final int GUARD_INTERVAL_PN_945_VARIOUS =
132             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.PN_945_VARIOUS;
133     /**
134      * PN_420_CONST Guard Interval.
135      */
136     public static final int GUARD_INTERVAL_PN_420_CONST =
137             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.PN_420_CONST;
138     /**
139      * PN_945_CONST Guard Interval.
140      */
141     public static final int GUARD_INTERVAL_PN_945_CONST =
142             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.PN_945_CONST;
143     /**
144      * PN_RESERVED Guard Interval.
145      */
146     public static final int GUARD_INTERVAL_PN_RESERVED =
147             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbGuardInterval.PN_RESERVED;
148 
149 
150     /** @hide */
151     @IntDef(flag = true,
152             prefix = "MODULATION_",
153             value = {MODULATION_CONSTELLATION_UNDEFINED, MODULATION_CONSTELLATION_AUTO,
154                     MODULATION_CONSTELLATION_4QAM, MODULATION_CONSTELLATION_4QAM_NR,
155                     MODULATION_CONSTELLATION_16QAM, MODULATION_CONSTELLATION_32QAM,
156                     MODULATION_CONSTELLATION_64QAM})
157     @Retention(RetentionPolicy.SOURCE)
158     public @interface Modulation {}
159 
160     /**
161      * Constellation not defined.
162      */
163     public static final int MODULATION_CONSTELLATION_UNDEFINED =
164             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.UNDEFINED;
165     /**
166      * Hardware is able to detect and set Constellation automatically.
167      */
168     public static final int MODULATION_CONSTELLATION_AUTO =
169             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.AUTO;
170     /**
171      * 4QAM Constellation.
172      */
173     public static final int MODULATION_CONSTELLATION_4QAM =
174             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.CONSTELLATION_4QAM;
175     /**
176      * 4QAM_NR Constellation.
177      */
178     public static final int MODULATION_CONSTELLATION_4QAM_NR =
179             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.CONSTELLATION_4QAM_NR;
180     /**
181      * 16QAM Constellation.
182      */
183     public static final int MODULATION_CONSTELLATION_16QAM =
184             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.CONSTELLATION_16QAM;
185     /**
186      * 32QAM Constellation.
187      */
188     public static final int MODULATION_CONSTELLATION_32QAM =
189             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.CONSTELLATION_32QAM;
190     /**
191      * 64QAM Constellation.
192      */
193     public static final int MODULATION_CONSTELLATION_64QAM =
194             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbModulation.CONSTELLATION_64QAM;
195 
196     /** @hide */
197     @IntDef(flag = true,
198             prefix = "CODERATE_",
199             value = {CODERATE_UNDEFINED, CODERATE_AUTO, CODERATE_2_5, CODERATE_3_5, CODERATE_4_5})
200     @Retention(RetentionPolicy.SOURCE)
201     public @interface CodeRate {}
202 
203     /**
204      * Code rate undefined.
205      */
206     public static final int CODERATE_UNDEFINED =
207             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbCodeRate.UNDEFINED;
208     /**
209      * Hardware is able to detect and set code rate automatically.
210      */
211     public static final int CODERATE_AUTO =
212             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbCodeRate.AUTO;
213     /**
214      * 2/5 code rate.
215      */
216     public static final int CODERATE_2_5 =
217             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbCodeRate.CODERATE_2_5;
218     /**
219      * 3/5 code rate.
220      */
221     public static final int CODERATE_3_5 =
222             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbCodeRate.CODERATE_3_5;
223     /**
224      * 4/5 code rate.
225      */
226     public static final int CODERATE_4_5 =
227             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbCodeRate.CODERATE_4_5;
228 
229     /** @hide */
230     @IntDef(flag = true,
231             prefix = "TRANSMISSION_MODE_",
232             value = {TRANSMISSION_MODE_UNDEFINED, TRANSMISSION_MODE_AUTO,
233                     TRANSMISSION_MODE_C1, TRANSMISSION_MODE_C3780})
234     @Retention(RetentionPolicy.SOURCE)
235     public @interface TransmissionMode {}
236 
237     /**
238      * Transmission Mode undefined.
239      */
240     public static final int TRANSMISSION_MODE_UNDEFINED =
241             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTransmissionMode.UNDEFINED;
242     /**
243      * Hardware is able to detect and set Transmission Mode automatically
244      */
245     public static final int TRANSMISSION_MODE_AUTO =
246             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTransmissionMode.AUTO;
247     /**
248      * C1 Transmission Mode.
249      */
250     public static final int TRANSMISSION_MODE_C1 =
251             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTransmissionMode.C1;
252     /**
253      * C3780 Transmission Mode.
254      */
255     public static final int TRANSMISSION_MODE_C3780 =
256             android.hardware.tv.tuner.V1_1.Constants.FrontendDtmbTransmissionMode.C3780;
257 
258 
259     private final int mModulation;
260     private final int mCodeRate;
261     private final int mTransmissionMode;
262     private final int mBandwidth;
263     private final int mGuardInterval;
264     private final int mTimeInterleaveMode;
265 
DtmbFrontendSettings(int frequency, int modulation, int codeRate, int transmissionMode, int guardInterval, int timeInterleaveMode, int bandwidth)266     private DtmbFrontendSettings(int frequency, int modulation, int codeRate, int transmissionMode,
267             int guardInterval, int timeInterleaveMode, int bandwidth) {
268         super(frequency);
269         mModulation = modulation;
270         mCodeRate = codeRate;
271         mTransmissionMode = transmissionMode;
272         mGuardInterval = guardInterval;
273         mTimeInterleaveMode = timeInterleaveMode;
274         mBandwidth = bandwidth;
275     }
276 
277     /**
278      * Gets Modulation.
279      */
280     @Modulation
getModulation()281     public int getModulation() {
282         return mModulation;
283     }
284 
285     /**
286      * Gets Code Rate.
287      */
288     @Modulation
getCodeRate()289     public int getCodeRate() {
290         return mCodeRate;
291     }
292 
293     /**
294      * Gets Transmission Mode.
295      */
296     @Modulation
getTransmissionMode()297     public int getTransmissionMode() {
298         return mTransmissionMode;
299     }
300 
301     /**
302      * Gets Bandwidth.
303      */
304     @Modulation
getBandwidth()305     public int getBandwidth() {
306         return mBandwidth;
307     }
308 
309     /**
310      * Gets Time Interleave Mode.
311      */
312     @Modulation
getTimeInterleaveMode()313     public int getTimeInterleaveMode() {
314         return mTimeInterleaveMode;
315     }
316 
317 
318     /**
319      * Gets Guard Interval.
320      */
321     @Modulation
getGuardInterval()322     public int getGuardInterval() {
323         return mGuardInterval;
324     }
325 
326     /**
327      * Creates a builder for {@link AtscFrontendSettings}.
328      */
329     @NonNull
builder()330     public static Builder builder() {
331         return new Builder();
332     }
333 
334     /**
335      * Builder for {@link AtscFrontendSettings}.
336      */
337     public static final class Builder {
338         private int mFrequency = 0;
339         private int mModulation = MODULATION_CONSTELLATION_UNDEFINED;
340         private int mCodeRate = CODERATE_UNDEFINED;
341         private int mTransmissionMode = TRANSMISSION_MODE_UNDEFINED;
342         private int mBandwidth = BANDWIDTH_UNDEFINED;
343         private int mTimeInterleaveMode = TIME_INTERLEAVE_MODE_UNDEFINED;
344         private int mGuardInterval = GUARD_INTERVAL_UNDEFINED;
345 
Builder()346         private Builder() {
347         }
348 
349         /**
350          * Sets frequency in Hz.
351          *
352          * <p>Default value is 0.
353          */
354         @NonNull
355         @IntRange(from = 1)
356         @SuppressLint("MissingGetterMatchingBuilder")
setFrequency(int frequency)357         public Builder setFrequency(int frequency) {
358             mFrequency = frequency;
359             return this;
360         }
361 
362         /**
363          * Sets Modulation.
364          *
365          * <p>Default value is {@link #MODULATION_CONSTELLATION_UNDEFINED}.
366          */
367         @NonNull
setModulation(@odulation int modulation)368         public Builder setModulation(@Modulation int modulation) {
369             mModulation = modulation;
370             return this;
371         }
372 
373         /**
374          * Sets Code Rate.
375          *
376          * <p>Default value is {@link #CODERATE_UNDEFINED}.
377          */
378         @NonNull
setCodeRate(@odeRate int codeRate)379         public Builder setCodeRate(@CodeRate int codeRate) {
380             mCodeRate = codeRate;
381             return this;
382         }
383 
384         /**
385          * Sets Bandwidth.
386          *
387          * <p>Default value is {@link #BANDWIDTH_UNDEFINED}.
388          */
389         @NonNull
setBandwidth(@andwidth int bandwidth)390         public Builder setBandwidth(@Bandwidth int bandwidth) {
391             mBandwidth = bandwidth;
392             return this;
393         }
394 
395         /**
396          * Sets Time Interleave Mode.
397          *
398          * <p>Default value is {@link #TIME_INTERLEAVE_MODE_UNDEFINED}.
399          */
400         @NonNull
setTimeInterleaveMode(@imeInterleaveMode int timeInterleaveMode)401         public Builder setTimeInterleaveMode(@TimeInterleaveMode int timeInterleaveMode) {
402             mTimeInterleaveMode = timeInterleaveMode;
403             return this;
404         }
405 
406         /**
407          * Sets Guard Interval.
408          *
409          * <p>Default value is {@link #GUARD_INTERVAL_UNDEFINED}.
410          */
411         @NonNull
setGuardInterval(@uardInterval int guardInterval)412         public Builder setGuardInterval(@GuardInterval int guardInterval) {
413             mGuardInterval = guardInterval;
414             return this;
415         }
416         /**
417          * Sets Transmission Mode.
418          *
419          * <p>Default value is {@link #TRANSMISSION_MODE_UNDEFINED}.
420          */
421         @NonNull
setTransmissionMode(@ransmissionMode int transmissionMode)422         public Builder setTransmissionMode(@TransmissionMode int transmissionMode) {
423             mTransmissionMode = transmissionMode;
424             return this;
425         }
426 
427         /**
428          * Builds a {@link DtmbFrontendSettings} object.
429          */
430         @NonNull
build()431         public DtmbFrontendSettings build() {
432             return new DtmbFrontendSettings(mFrequency, mModulation, mCodeRate,
433                     mTransmissionMode, mGuardInterval, mTimeInterleaveMode, mBandwidth);
434         }
435     }
436 
437     @Override
getType()438     public int getType() {
439         return FrontendSettings.TYPE_DTMB;
440     }
441 }
442