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.TunerVersionChecker;
25 
26 import java.lang.annotation.Retention;
27 import java.lang.annotation.RetentionPolicy;
28 
29 /**
30  * Frontend settings for DVBT.
31  *
32  * @hide
33  */
34 @SystemApi
35 public class DvbtFrontendSettings extends FrontendSettings {
36 
37     /** @hide */
38     @IntDef(flag = true,
39             prefix = "TRANSMISSION_MODE_",
40             value = {TRANSMISSION_MODE_UNDEFINED, TRANSMISSION_MODE_AUTO,
41                     TRANSMISSION_MODE_2K, TRANSMISSION_MODE_8K, TRANSMISSION_MODE_4K,
42                     TRANSMISSION_MODE_1K, TRANSMISSION_MODE_16K, TRANSMISSION_MODE_32K})
43     @Retention(RetentionPolicy.SOURCE)
44     public @interface TransmissionMode {}
45 
46     /**
47      * Transmission Mode undefined.
48      */
49     public static final int TRANSMISSION_MODE_UNDEFINED =
50             Constants.FrontendDvbtTransmissionMode.UNDEFINED;
51     /**
52      * Hardware is able to detect and set Transmission Mode automatically
53      */
54     public static final int TRANSMISSION_MODE_AUTO = Constants.FrontendDvbtTransmissionMode.AUTO;
55     /**
56      * 2K Transmission Mode.
57      */
58     public static final int TRANSMISSION_MODE_2K = Constants.FrontendDvbtTransmissionMode.MODE_2K;
59     /**
60      * 8K Transmission Mode.
61      */
62     public static final int TRANSMISSION_MODE_8K = Constants.FrontendDvbtTransmissionMode.MODE_8K;
63     /**
64      * 4K Transmission Mode.
65      */
66     public static final int TRANSMISSION_MODE_4K = Constants.FrontendDvbtTransmissionMode.MODE_4K;
67     /**
68      * 1K Transmission Mode.
69      */
70     public static final int TRANSMISSION_MODE_1K = Constants.FrontendDvbtTransmissionMode.MODE_1K;
71     /**
72      * 16K Transmission Mode.
73      */
74     public static final int TRANSMISSION_MODE_16K = Constants.FrontendDvbtTransmissionMode.MODE_16K;
75     /**
76      * 32K Transmission Mode.
77      */
78     public static final int TRANSMISSION_MODE_32K = Constants.FrontendDvbtTransmissionMode.MODE_32K;
79     /**
80      * 8K Transmission Extended Mode.
81      */
82     public static final int TRANSMISSION_MODE_EXTENDED_8K =
83             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtTransmissionMode.MODE_8K_E;
84     /**
85      * 16K Transmission Extended Mode.
86      */
87     public static final int TRANSMISSION_MODE_EXTENDED_16K =
88             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtTransmissionMode.MODE_16K_E;
89     /**
90      * 32K Transmission Extended Mode.
91      */
92     public static final int TRANSMISSION_MODE_EXTENDED_32K =
93             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtTransmissionMode.MODE_32K_E;
94 
95     /** @hide */
96     @IntDef(flag = true,
97             prefix = "BANDWIDTH_",
98             value = {BANDWIDTH_UNDEFINED, BANDWIDTH_AUTO, BANDWIDTH_8MHZ, BANDWIDTH_7MHZ,
99                     BANDWIDTH_6MHZ, BANDWIDTH_5MHZ, BANDWIDTH_1_7MHZ, BANDWIDTH_10MHZ})
100     @Retention(RetentionPolicy.SOURCE)
101     public @interface Bandwidth {}
102 
103     /**
104      * Bandwidth undefined.
105      */
106     public static final int BANDWIDTH_UNDEFINED = Constants.FrontendDvbtBandwidth.UNDEFINED;
107     /**
108      * Hardware is able to detect and set Bandwidth automatically.
109      */
110     public static final int BANDWIDTH_AUTO = Constants.FrontendDvbtBandwidth.AUTO;
111     /**
112      * 8 MHz bandwidth.
113      */
114     public static final int BANDWIDTH_8MHZ = Constants.FrontendDvbtBandwidth.BANDWIDTH_8MHZ;
115     /**
116      * 7 MHz bandwidth.
117      */
118     public static final int BANDWIDTH_7MHZ = Constants.FrontendDvbtBandwidth.BANDWIDTH_7MHZ;
119     /**
120      * 6 MHz bandwidth.
121      */
122     public static final int BANDWIDTH_6MHZ = Constants.FrontendDvbtBandwidth.BANDWIDTH_6MHZ;
123     /**
124      * 5 MHz bandwidth.
125      */
126     public static final int BANDWIDTH_5MHZ = Constants.FrontendDvbtBandwidth.BANDWIDTH_5MHZ;
127     /**
128      * 1,7 MHz bandwidth.
129      */
130     public static final int BANDWIDTH_1_7MHZ = Constants.FrontendDvbtBandwidth.BANDWIDTH_1_7MHZ;
131     /**
132      * 10 MHz bandwidth.
133      */
134     public static final int BANDWIDTH_10MHZ = Constants.FrontendDvbtBandwidth.BANDWIDTH_10MHZ;
135 
136 
137     /** @hide */
138     @IntDef(flag = true,
139             prefix = "CONSTELLATION_",
140             value = {CONSTELLATION_UNDEFINED, CONSTELLATION_AUTO, CONSTELLATION_QPSK,
141                     CONSTELLATION_16QAM, CONSTELLATION_64QAM, CONSTELLATION_256QAM,
142                     CONSTELLATION_QPSK_R, CONSTELLATION_16QAM_R, CONSTELLATION_64QAM_R,
143                     CONSTELLATION_256QAM_R})
144     @Retention(RetentionPolicy.SOURCE)
145     public @interface Constellation {}
146 
147     /**
148      * Constellation not defined.
149      */
150     public static final int CONSTELLATION_UNDEFINED = Constants.FrontendDvbtConstellation.UNDEFINED;
151     /**
152      * Hardware is able to detect and set Constellation automatically.
153      */
154     public static final int CONSTELLATION_AUTO = Constants.FrontendDvbtConstellation.AUTO;
155     /**
156      * QPSK Constellation.
157      */
158     public static final int CONSTELLATION_QPSK =
159             Constants.FrontendDvbtConstellation.CONSTELLATION_QPSK;
160     /**
161      * 16QAM Constellation.
162      */
163     public static final int CONSTELLATION_16QAM =
164             Constants.FrontendDvbtConstellation.CONSTELLATION_16QAM;
165     /**
166      * 64QAM Constellation.
167      */
168     public static final int CONSTELLATION_64QAM =
169             Constants.FrontendDvbtConstellation.CONSTELLATION_64QAM;
170     /**
171      * 256QAM Constellation.
172      */
173     public static final int CONSTELLATION_256QAM =
174             Constants.FrontendDvbtConstellation.CONSTELLATION_256QAM;
175     /**
176      * QPSK Rotated Constellation.
177      */
178     public static final int CONSTELLATION_QPSK_R =
179             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtConstellation
180                     .CONSTELLATION_QPSK_R;
181     /**
182      * 16QAM Rotated Constellation.
183      */
184     public static final int CONSTELLATION_16QAM_R =
185             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtConstellation
186                     .CONSTELLATION_16QAM_R;
187     /**
188      * 64QAM Rotated Constellation.
189      */
190     public static final int CONSTELLATION_64QAM_R =
191             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtConstellation
192                     .CONSTELLATION_64QAM_R;
193     /**
194      * 256QAM Rotated Constellation.
195      */
196     public static final int CONSTELLATION_256QAM_R =
197             android.hardware.tv.tuner.V1_1.Constants.FrontendDvbtConstellation
198                     .CONSTELLATION_256QAM_R;
199 
200     /** @hide */
201     @IntDef(flag = true,
202             prefix = "HIERARCHY_",
203             value = {HIERARCHY_UNDEFINED, HIERARCHY_AUTO, HIERARCHY_NON_NATIVE, HIERARCHY_1_NATIVE,
204             HIERARCHY_2_NATIVE, HIERARCHY_4_NATIVE, HIERARCHY_NON_INDEPTH, HIERARCHY_1_INDEPTH,
205             HIERARCHY_2_INDEPTH, HIERARCHY_4_INDEPTH})
206     @Retention(RetentionPolicy.SOURCE)
207     public @interface Hierarchy {}
208 
209     /**
210      * Hierarchy undefined.
211      */
212     public static final int HIERARCHY_UNDEFINED = Constants.FrontendDvbtHierarchy.UNDEFINED;
213     /**
214      * Hardware is able to detect and set Hierarchy automatically.
215      */
216     public static final int HIERARCHY_AUTO = Constants.FrontendDvbtHierarchy.AUTO;
217     /**
218      * Non-native Hierarchy
219      */
220     public static final int HIERARCHY_NON_NATIVE =
221             Constants.FrontendDvbtHierarchy.HIERARCHY_NON_NATIVE;
222     /**
223      * 1-native Hierarchy
224      */
225     public static final int HIERARCHY_1_NATIVE = Constants.FrontendDvbtHierarchy.HIERARCHY_1_NATIVE;
226     /**
227      * 2-native Hierarchy
228      */
229     public static final int HIERARCHY_2_NATIVE = Constants.FrontendDvbtHierarchy.HIERARCHY_2_NATIVE;
230     /**
231      * 4-native Hierarchy
232      */
233     public static final int HIERARCHY_4_NATIVE = Constants.FrontendDvbtHierarchy.HIERARCHY_4_NATIVE;
234     /**
235      * Non-indepth Hierarchy
236      */
237     public static final int HIERARCHY_NON_INDEPTH =
238             Constants.FrontendDvbtHierarchy.HIERARCHY_NON_INDEPTH;
239     /**
240      * 1-indepth Hierarchy
241      */
242     public static final int HIERARCHY_1_INDEPTH =
243             Constants.FrontendDvbtHierarchy.HIERARCHY_1_INDEPTH;
244     /**
245      * 2-indepth Hierarchy
246      */
247     public static final int HIERARCHY_2_INDEPTH =
248             Constants.FrontendDvbtHierarchy.HIERARCHY_2_INDEPTH;
249     /**
250      * 4-indepth Hierarchy
251      */
252     public static final int HIERARCHY_4_INDEPTH =
253             Constants.FrontendDvbtHierarchy.HIERARCHY_4_INDEPTH;
254 
255 
256     /** @hide */
257     @IntDef(flag = true,
258             prefix = "CODERATE_",
259             value = {CODERATE_UNDEFINED, CODERATE_AUTO, CODERATE_1_2, CODERATE_2_3, CODERATE_3_4,
260             CODERATE_5_6, CODERATE_7_8, CODERATE_3_5, CODERATE_4_5, CODERATE_6_7, CODERATE_8_9})
261     @Retention(RetentionPolicy.SOURCE)
262     public @interface CodeRate {}
263 
264     /**
265      * Code rate undefined.
266      */
267     public static final int CODERATE_UNDEFINED =
268             Constants.FrontendDvbtCoderate.UNDEFINED;
269     /**
270      * Hardware is able to detect and set code rate automatically.
271      */
272     public static final int CODERATE_AUTO = Constants.FrontendDvbtCoderate.AUTO;
273     /**
274      * 1/2 code rate.
275      */
276     public static final int CODERATE_1_2 = Constants.FrontendDvbtCoderate.CODERATE_1_2;
277     /**
278      * 2/3 code rate.
279      */
280     public static final int CODERATE_2_3 = Constants.FrontendDvbtCoderate.CODERATE_2_3;
281     /**
282      * 3/4 code rate.
283      */
284     public static final int CODERATE_3_4 = Constants.FrontendDvbtCoderate.CODERATE_3_4;
285     /**
286      * 5/6 code rate.
287      */
288     public static final int CODERATE_5_6 = Constants.FrontendDvbtCoderate.CODERATE_5_6;
289     /**
290      * 7/8 code rate.
291      */
292     public static final int CODERATE_7_8 = Constants.FrontendDvbtCoderate.CODERATE_7_8;
293     /**
294      * 4/5 code rate.
295      */
296     public static final int CODERATE_3_5 = Constants.FrontendDvbtCoderate.CODERATE_3_5;
297     /**
298      * 4/5 code rate.
299      */
300     public static final int CODERATE_4_5 = Constants.FrontendDvbtCoderate.CODERATE_4_5;
301     /**
302      * 6/7 code rate.
303      */
304     public static final int CODERATE_6_7 = Constants.FrontendDvbtCoderate.CODERATE_6_7;
305     /**
306      * 8/9 code rate.
307      */
308     public static final int CODERATE_8_9 = Constants.FrontendDvbtCoderate.CODERATE_8_9;
309 
310     /** @hide */
311     @IntDef(flag = true,
312             prefix = "GUARD_INTERVAL_",
313             value = {GUARD_INTERVAL_UNDEFINED, GUARD_INTERVAL_AUTO,
314             GUARD_INTERVAL_1_32, GUARD_INTERVAL_1_16,
315             GUARD_INTERVAL_1_8, GUARD_INTERVAL_1_4,
316             GUARD_INTERVAL_1_128,
317             GUARD_INTERVAL_19_128,
318             GUARD_INTERVAL_19_256})
319     @Retention(RetentionPolicy.SOURCE)
320     public @interface GuardInterval {}
321 
322     /**
323      * Guard Interval undefined.
324      */
325     public static final int GUARD_INTERVAL_UNDEFINED =
326             Constants.FrontendDvbtGuardInterval.UNDEFINED;
327     /**
328      * Hardware is able to detect and set Guard Interval automatically.
329      */
330     public static final int GUARD_INTERVAL_AUTO = Constants.FrontendDvbtGuardInterval.AUTO;
331     /**
332      * 1/32 Guard Interval.
333      */
334     public static final int GUARD_INTERVAL_1_32 =
335             Constants.FrontendDvbtGuardInterval.INTERVAL_1_32;
336     /**
337      * 1/16 Guard Interval.
338      */
339     public static final int GUARD_INTERVAL_1_16 =
340             Constants.FrontendDvbtGuardInterval.INTERVAL_1_16;
341     /**
342      * 1/8 Guard Interval.
343      */
344     public static final int GUARD_INTERVAL_1_8 =
345             Constants.FrontendDvbtGuardInterval.INTERVAL_1_8;
346     /**
347      * 1/4 Guard Interval.
348      */
349     public static final int GUARD_INTERVAL_1_4 =
350             Constants.FrontendDvbtGuardInterval.INTERVAL_1_4;
351     /**
352      * 1/128 Guard Interval.
353      */
354     public static final int GUARD_INTERVAL_1_128 =
355             Constants.FrontendDvbtGuardInterval.INTERVAL_1_128;
356     /**
357      * 19/128 Guard Interval.
358      */
359     public static final int GUARD_INTERVAL_19_128 =
360             Constants.FrontendDvbtGuardInterval.INTERVAL_19_128;
361     /**
362      * 19/256 Guard Interval.
363      */
364     public static final int GUARD_INTERVAL_19_256 =
365             Constants.FrontendDvbtGuardInterval.INTERVAL_19_256;
366 
367     /** @hide */
368     @IntDef(flag = true,
369             prefix = "STANDARD",
370             value = {STANDARD_AUTO, STANDARD_T, STANDARD_T2}
371     )
372     @Retention(RetentionPolicy.SOURCE)
373     public @interface Standard {}
374 
375     /**
376      * Hardware is able to detect and set Standard automatically.
377      */
378     public static final int STANDARD_AUTO = Constants.FrontendDvbtStandard.AUTO;
379     /**
380      * T standard.
381      */
382     public static final int STANDARD_T = Constants.FrontendDvbtStandard.T;
383     /**
384      * T2 standard.
385      */
386     public static final int STANDARD_T2 = Constants.FrontendDvbtStandard.T2;
387 
388     /** @hide */
389     @IntDef(prefix = "PLP_MODE_",
390             value = {PLP_MODE_UNDEFINED, PLP_MODE_AUTO, PLP_MODE_MANUAL})
391     @Retention(RetentionPolicy.SOURCE)
392     public @interface PlpMode {}
393 
394     /**
395      * Physical Layer Pipe (PLP) Mode undefined.
396      */
397     public static final int PLP_MODE_UNDEFINED = Constants.FrontendDvbtPlpMode.UNDEFINED;
398     /**
399      * Hardware is able to detect and set Physical Layer Pipe (PLP) Mode automatically.
400      */
401     public static final int PLP_MODE_AUTO = Constants.FrontendDvbtPlpMode.AUTO;
402     /**
403      * Physical Layer Pipe (PLP) manual Mode.
404      */
405     public static final int PLP_MODE_MANUAL = Constants.FrontendDvbtPlpMode.MANUAL;
406 
407     private int mTransmissionMode;
408     private final int mBandwidth;
409     private final int mConstellation;
410     private final int mHierarchy;
411     private final int mHpCodeRate;
412     private final int mLpCodeRate;
413     private final int mGuardInterval;
414     private final boolean mIsHighPriority;
415     private final int mStandard;
416     private final boolean mIsMiso;
417     private final int mPlpMode;
418     private final int mPlpId;
419     private final int mPlpGroupId;
420 
DvbtFrontendSettings(int frequency, int transmissionMode, int bandwidth, int constellation, int hierarchy, int hpCodeRate, int lpCodeRate, int guardInterval, boolean isHighPriority, int standard, boolean isMiso, int plpMode, int plpId, int plpGroupId)421     private DvbtFrontendSettings(int frequency, int transmissionMode, int bandwidth,
422             int constellation, int hierarchy, int hpCodeRate, int lpCodeRate, int guardInterval,
423             boolean isHighPriority, int standard, boolean isMiso, int plpMode, int plpId,
424             int plpGroupId) {
425         super(frequency);
426         mTransmissionMode = transmissionMode;
427         mBandwidth = bandwidth;
428         mConstellation = constellation;
429         mHierarchy = hierarchy;
430         mHpCodeRate = hpCodeRate;
431         mLpCodeRate = lpCodeRate;
432         mGuardInterval = guardInterval;
433         mIsHighPriority = isHighPriority;
434         mStandard = standard;
435         mIsMiso = isMiso;
436         mPlpMode = plpMode;
437         mPlpId = plpId;
438         mPlpGroupId = plpGroupId;
439     }
440 
441     /**
442      * Gets Transmission Mode.
443      */
444     @TransmissionMode
getTransmissionMode()445     public int getTransmissionMode() {
446         return mTransmissionMode;
447     }
448     /**
449      * Gets Bandwidth.
450      */
451     @Bandwidth
getBandwidth()452     public int getBandwidth() {
453         return mBandwidth;
454     }
455     /**
456      * Gets Constellation.
457      */
458     @Constellation
getConstellation()459     public int getConstellation() {
460         return mConstellation;
461     }
462     /**
463      * Gets Hierarchy.
464      */
465     @Hierarchy
getHierarchy()466     public int getHierarchy() {
467         return mHierarchy;
468     }
469     /**
470      * Gets Code Rate for High Priority level.
471      */
472     @CodeRate
getHighPriorityCodeRate()473     public int getHighPriorityCodeRate() {
474         return mHpCodeRate;
475     }
476     /**
477      * Gets Code Rate for Low Priority level.
478      */
479     @CodeRate
getLowPriorityCodeRate()480     public int getLowPriorityCodeRate() {
481         return mLpCodeRate;
482     }
483     /**
484      * Gets Guard Interval.
485      */
486     @GuardInterval
getGuardInterval()487     public int getGuardInterval() {
488         return mGuardInterval;
489     }
490     /**
491      * Checks whether it's high priority.
492      */
isHighPriority()493     public boolean isHighPriority() {
494         return mIsHighPriority;
495     }
496     /**
497      * Gets Standard.
498      */
499     @Standard
getStandard()500     public int getStandard() {
501         return mStandard;
502     }
503     /**
504      * Gets whether it's MISO.
505      */
isMiso()506     public boolean isMiso() {
507         return mIsMiso;
508     }
509     /**
510      * Gets Physical Layer Pipe (PLP) Mode.
511      */
512     @PlpMode
getPlpMode()513     public int getPlpMode() {
514         return mPlpMode;
515     }
516     /**
517      * Gets Physical Layer Pipe (PLP) ID.
518      */
getPlpId()519     public int getPlpId() {
520         return mPlpId;
521     }
522     /**
523      * Gets Physical Layer Pipe (PLP) group ID.
524      */
getPlpGroupId()525     public int getPlpGroupId() {
526         return mPlpGroupId;
527     }
528 
isExtendedTransmissionMode(@ransmissionMode int transmissionMode)529     private static boolean isExtendedTransmissionMode(@TransmissionMode int transmissionMode) {
530         return transmissionMode == TRANSMISSION_MODE_EXTENDED_8K
531                 || transmissionMode == TRANSMISSION_MODE_EXTENDED_16K
532                 || transmissionMode == TRANSMISSION_MODE_EXTENDED_32K;
533     }
534 
isExtendedConstellation(@onstellation int constellation)535     private static boolean isExtendedConstellation(@Constellation int constellation) {
536         return constellation == CONSTELLATION_QPSK_R
537                 || constellation == CONSTELLATION_16QAM_R
538                 || constellation == CONSTELLATION_64QAM_R
539                 || constellation == CONSTELLATION_256QAM_R;
540     }
541 
542     /**
543      * Creates a builder for {@link DvbtFrontendSettings}.
544      */
545     @NonNull
builder()546     public static Builder builder() {
547         return new Builder();
548     }
549 
550     /**
551      * Builder for {@link DvbtFrontendSettings}.
552      */
553     public static class Builder {
554         private int mFrequency = 0;
555         private int mTransmissionMode = TRANSMISSION_MODE_UNDEFINED;
556         private int mBandwidth = BANDWIDTH_UNDEFINED;
557         private int mConstellation = CONSTELLATION_UNDEFINED;
558         private int mHierarchy = HIERARCHY_UNDEFINED;
559         private int mHpCodeRate = CODERATE_UNDEFINED;
560         private int mLpCodeRate = CODERATE_UNDEFINED;
561         private int mGuardInterval = GUARD_INTERVAL_UNDEFINED;
562         private boolean mIsHighPriority = false;
563         private int mStandard = STANDARD_AUTO;
564         private boolean mIsMiso = false;
565         private int mPlpMode = PLP_MODE_UNDEFINED;
566         private int mPlpId = 0;
567         private int mPlpGroupId = 0;
568 
Builder()569         private Builder() {
570         }
571 
572         /**
573          * Sets frequency in Hz.
574          *
575          * <p>Default value is 0.
576          */
577         @NonNull
578         @IntRange(from = 1)
setFrequency(int frequency)579         public Builder setFrequency(int frequency) {
580             mFrequency = frequency;
581             return this;
582         }
583 
584         /**
585          * Sets Transmission Mode.
586          *
587          * <p>{@link #TRANSMISSION_MODE_EXTENDED_8K}, {@link #TRANSMISSION_MODE_EXTENDED_16K} and
588          * {@link #TRANSMISSION_MODE_EXTENDED_32K} are only supported by Tuner HAL 1.1 or higher.
589          * Unsupported version would cause no-op. Use {@link TunerVersionChecker#getTunerVersion()}
590          * to check the version.
591          *
592          * <p>Default value is {@link #TRANSMISSION_MODE_UNDEFINED}.
593          */
594         @NonNull
setTransmissionMode(@ransmissionMode int transmissionMode)595         public Builder setTransmissionMode(@TransmissionMode int transmissionMode) {
596             if (!isExtendedTransmissionMode(transmissionMode)
597                     || TunerVersionChecker.checkHigherOrEqualVersionTo(
598                             TunerVersionChecker.TUNER_VERSION_1_1, "set TransmissionMode Ext")) {
599                 mTransmissionMode = transmissionMode;
600             }
601             return this;
602         }
603 
604         /**
605          * Sets Bandwidth.
606          *
607          * <p>Default value is {@link #BANDWIDTH_UNDEFINED}.
608          */
609         @NonNull
setBandwidth(@andwidth int bandwidth)610         public Builder setBandwidth(@Bandwidth int bandwidth) {
611             mBandwidth = bandwidth;
612             return this;
613         }
614         /**
615          * Sets Constellation.
616          *
617          * <p>{@link #CONSTELLATION_QPSK_R}, {@link #CONSTELLATION_16QAM_R},
618          * {@link #CONSTELLATION_64QAM_R} and {@link #CONSTELLATION_256QAM_Rare} are only supported
619          * by Tuner HAL 1.1 or higher. Unsupported version would cause no-op. Use
620          * {@link TunerVersionChecker#getTunerVersion()} to check the version.
621          *
622          * <p>Default value is {@link #CONSTELLATION_UNDEFINED}.
623          */
624         @NonNull
setConstellation(@onstellation int constellation)625         public Builder setConstellation(@Constellation int constellation) {
626             if (!isExtendedConstellation(constellation)
627                     || TunerVersionChecker.checkHigherOrEqualVersionTo(
628                             TunerVersionChecker.TUNER_VERSION_1_1, "set Constellation Ext")) {
629                 mConstellation = constellation;
630             }
631             return this;
632         }
633         /**
634          * Sets Hierarchy.
635          *
636          * <p>Default value is {@link #HIERARCHY_UNDEFINED}.
637          */
638         @NonNull
setHierarchy(@ierarchy int hierarchy)639         public Builder setHierarchy(@Hierarchy int hierarchy) {
640             mHierarchy = hierarchy;
641             return this;
642         }
643         /**
644          * Sets Code Rate for High Priority level.
645          *
646          * <p>Default value is {@link #CODERATE_UNDEFINED}.
647          */
648         @NonNull
setHighPriorityCodeRate(@odeRate int hpCodeRate)649         public Builder setHighPriorityCodeRate(@CodeRate int hpCodeRate) {
650             mHpCodeRate = hpCodeRate;
651             return this;
652         }
653         /**
654          * Sets Code Rate for Low Priority level.
655          *
656          * <p>Default value is {@link #CODERATE_UNDEFINED}.
657          */
658         @NonNull
setLowPriorityCodeRate(@odeRate int lpCodeRate)659         public Builder setLowPriorityCodeRate(@CodeRate int lpCodeRate) {
660             mLpCodeRate = lpCodeRate;
661             return this;
662         }
663         /**
664          * Sets Guard Interval.
665          *
666          * <p>Default value is {@link #GUARD_INTERVAL_UNDEFINED}.
667          */
668         @NonNull
setGuardInterval(@uardInterval int guardInterval)669         public Builder setGuardInterval(@GuardInterval int guardInterval) {
670             mGuardInterval = guardInterval;
671             return this;
672         }
673         /**
674          * Sets whether it's high priority.
675          *
676          * <p>Default value is {@code false}.
677          */
678         @NonNull
setHighPriority(boolean isHighPriority)679         public Builder setHighPriority(boolean isHighPriority) {
680             mIsHighPriority = isHighPriority;
681             return this;
682         }
683         /**
684          * Sets Standard.
685          *
686          * <p>Default value is {@link #STANDARD_AUTO}.
687          */
688         @NonNull
setStandard(@tandard int standard)689         public Builder setStandard(@Standard int standard) {
690             mStandard = standard;
691             return this;
692         }
693         /**
694          * Sets whether it's MISO.
695          *
696          * <p>Default value is {@code false}.
697          */
698         @NonNull
setMiso(boolean isMiso)699         public Builder setMiso(boolean isMiso) {
700             mIsMiso = isMiso;
701             return this;
702         }
703         /**
704          * Sets Physical Layer Pipe (PLP) Mode.
705          *
706          * <p>Default value is {@link #PLP_MODE_UNDEFINED}.
707          */
708         @NonNull
setPlpMode(@lpMode int plpMode)709         public Builder setPlpMode(@PlpMode int plpMode) {
710             mPlpMode = plpMode;
711             return this;
712         }
713         /**
714          * Sets Physical Layer Pipe (PLP) ID.
715          *
716          * <p>Default value is 0.
717          */
718         @NonNull
setPlpId(int plpId)719         public Builder setPlpId(int plpId) {
720             mPlpId = plpId;
721             return this;
722         }
723         /**
724          * Sets Physical Layer Pipe (PLP) group ID.
725          *
726          * <p>Default value is 0.
727          */
728         @NonNull
setPlpGroupId(int plpGroupId)729         public Builder setPlpGroupId(int plpGroupId) {
730             mPlpGroupId = plpGroupId;
731             return this;
732         }
733 
734         /**
735          * Builds a {@link DvbtFrontendSettings} object.
736          */
737         @NonNull
build()738         public DvbtFrontendSettings build() {
739             return new DvbtFrontendSettings(mFrequency, mTransmissionMode, mBandwidth,
740                     mConstellation, mHierarchy, mHpCodeRate, mLpCodeRate, mGuardInterval,
741                     mIsHighPriority, mStandard, mIsMiso, mPlpMode, mPlpId, mPlpGroupId);
742         }
743     }
744 
745     @Override
getType()746     public int getType() {
747         return FrontendSettings.TYPE_DVBT;
748     }
749 }
750