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 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * Frontend settings for analog tuner.
30  *
31  * @hide
32  */
33 @SystemApi
34 public class AnalogFrontendSettings extends FrontendSettings {
35     /** @hide */
36     @IntDef(flag = true,
37             prefix = "SIGNAL_TYPE_",
38             value = {SIGNAL_TYPE_UNDEFINED, SIGNAL_TYPE_AUTO, SIGNAL_TYPE_PAL, SIGNAL_TYPE_PAL_M,
39               SIGNAL_TYPE_PAL_N, SIGNAL_TYPE_PAL_60, SIGNAL_TYPE_NTSC, SIGNAL_TYPE_NTSC_443,
40               SIGNAL_TYPE_SECAM})
41     @Retention(RetentionPolicy.SOURCE)
42     public @interface SignalType {}
43 
44     /**
45      * Undefined analog signal type.
46      */
47     public static final int SIGNAL_TYPE_UNDEFINED = Constants.FrontendAnalogType.UNDEFINED;
48     /**
49      * AUTO analog signal type.
50      */
51     public static final int SIGNAL_TYPE_AUTO = Constants.FrontendAnalogType.AUTO;
52     /**
53      * PAL analog signal type.
54      */
55     public static final int SIGNAL_TYPE_PAL = Constants.FrontendAnalogType.PAL;
56     /**
57      * PAL M analog signal type.
58      */
59     public static final int SIGNAL_TYPE_PAL_M = Constants.FrontendAnalogType.PAL_M;
60     /**
61      * PAL N analog signal type.
62      */
63     public static final int SIGNAL_TYPE_PAL_N = Constants.FrontendAnalogType.PAL_N;
64     /**
65      * PAL 60 analog signal type.
66      */
67     public static final int SIGNAL_TYPE_PAL_60 = Constants.FrontendAnalogType.PAL_60;
68     /**
69      * NTSC analog signal type.
70      */
71     public static final int SIGNAL_TYPE_NTSC = Constants.FrontendAnalogType.NTSC;
72     /**
73      * NTSC 443 analog signal type.
74      */
75     public static final int SIGNAL_TYPE_NTSC_443 = Constants.FrontendAnalogType.NTSC_443;
76     /**
77      * SECM analog signal type.
78      */
79     public static final int SIGNAL_TYPE_SECAM = Constants.FrontendAnalogType.SECAM;
80 
81     /** @hide */
82     @IntDef(flag = true,
83             prefix = "SIF_",
84             value = {SIF_UNDEFINED, SIF_AUTO, SIF_BG, SIF_BG_A2, SIF_BG_NICAM, SIF_I, SIF_DK,
85             SIF_DK1_A2, SIF_DK2_A2, SIF_DK3_A2, SIF_DK_NICAM, SIF_L, SIF_M, SIF_M_BTSC, SIF_M_A2,
86             SIF_M_EIAJ, SIF_I_NICAM, SIF_L_NICAM, SIF_L_PRIME})
87     @Retention(RetentionPolicy.SOURCE)
88     public @interface SifStandard {}
89 
90     /**
91      * Undefined Analog Standard Interchange Format (SIF).
92      */
93     public static final int SIF_UNDEFINED = Constants.FrontendAnalogSifStandard.UNDEFINED;
94     /**
95      * Audo Analog Standard Interchange Format (SIF).
96      */
97     public static final int SIF_AUTO = Constants.FrontendAnalogSifStandard.AUTO;
98      /**
99      * BG Analog Standard Interchange Format (SIF).
100      */
101     public static final int SIF_BG = Constants.FrontendAnalogSifStandard.BG;
102     /**
103      * BG-A2 Analog Standard Interchange Format (SIF).
104      */
105     public static final int SIF_BG_A2 = Constants.FrontendAnalogSifStandard.BG_A2;
106     /**
107      * BG-NICAM Analog Standard Interchange Format (SIF).
108      */
109     public static final int SIF_BG_NICAM = Constants.FrontendAnalogSifStandard.BG_NICAM;
110     /**
111      * I Analog Standard Interchange Format (SIF).
112      */
113     public static final int SIF_I = Constants.FrontendAnalogSifStandard.I;
114     /**
115      * DK Analog Standard Interchange Format (SIF).
116      */
117     public static final int SIF_DK = Constants.FrontendAnalogSifStandard.DK;
118     /**
119      * DK1 A2 Analog Standard Interchange Format (SIF).
120      */
121     public static final int SIF_DK1_A2 = Constants.FrontendAnalogSifStandard.DK1_A2;
122     /**
123      * DK2 A2 Analog Standard Interchange Format (SIF).
124      */
125     public static final int SIF_DK2_A2 = Constants.FrontendAnalogSifStandard.DK2_A2;
126     /**
127      * DK3 A2 Analog Standard Interchange Format (SIF).
128      */
129     public static final int SIF_DK3_A2 = Constants.FrontendAnalogSifStandard.DK3_A2;
130     /**
131      * DK-NICAM Analog Standard Interchange Format (SIF).
132      */
133     public static final int SIF_DK_NICAM = Constants.FrontendAnalogSifStandard.DK_NICAM;
134     /**
135      * L Analog Standard Interchange Format (SIF).
136      */
137     public static final int SIF_L = Constants.FrontendAnalogSifStandard.L;
138     /**
139      * M Analog Standard Interchange Format (SIF).
140      */
141     public static final int SIF_M = Constants.FrontendAnalogSifStandard.M;
142     /**
143      * M-BTSC Analog Standard Interchange Format (SIF).
144      */
145     public static final int SIF_M_BTSC = Constants.FrontendAnalogSifStandard.M_BTSC;
146     /**
147      * M-A2 Analog Standard Interchange Format (SIF).
148      */
149     public static final int SIF_M_A2 = Constants.FrontendAnalogSifStandard.M_A2;
150     /**
151      * M-EIAJ Analog Standard Interchange Format (SIF).
152      */
153     public static final int SIF_M_EIAJ = Constants.FrontendAnalogSifStandard.M_EIAJ;
154     /**
155      * I-NICAM Analog Standard Interchange Format (SIF).
156      */
157     public static final int SIF_I_NICAM = Constants.FrontendAnalogSifStandard.I_NICAM;
158     /**
159      * L-NICAM Analog Standard Interchange Format (SIF).
160      */
161     public static final int SIF_L_NICAM = Constants.FrontendAnalogSifStandard.L_NICAM;
162     /**
163      * L-PRIME Analog Standard Interchange Format (SIF).
164      */
165     public static final int SIF_L_PRIME = Constants.FrontendAnalogSifStandard.L_PRIME;
166 
167 
168     private final int mSignalType;
169     private final int mSifStandard;
170 
171     @Override
getType()172     public int getType() {
173         return FrontendSettings.TYPE_ANALOG;
174     }
175 
176 
177     /**
178      * Gets analog signal type.
179      */
180     @SignalType
getSignalType()181     public int getSignalType() {
182         return mSignalType;
183     }
184 
185     /**
186      * Gets Standard Interchange Format (SIF).
187      */
188     @SifStandard
getSifStandard()189     public int getSifStandard() {
190         return mSifStandard;
191     }
192 
193     /**
194      * Creates a builder for {@link AnalogFrontendSettings}.
195      */
196     @NonNull
builder()197     public static Builder builder() {
198         return new Builder();
199     }
200 
AnalogFrontendSettings(int frequency, int signalType, int sifStandard)201     private AnalogFrontendSettings(int frequency, int signalType, int sifStandard) {
202         super(frequency);
203         mSignalType = signalType;
204         mSifStandard = sifStandard;
205     }
206 
207     /**
208      * Builder for {@link AnalogFrontendSettings}.
209      */
210     public static class Builder {
211         private int mFrequency = 0;
212         private int mSignalType = SIGNAL_TYPE_UNDEFINED;
213         private int mSifStandard = SIF_UNDEFINED;
214 
Builder()215         private Builder() {}
216 
217         /**
218          * Sets frequency in Hz.
219          *
220          * <p>Default value is 0.
221          */
222         @NonNull
223         @IntRange(from = 1)
setFrequency(int frequency)224         public Builder setFrequency(int frequency) {
225             mFrequency = frequency;
226             return this;
227         }
228 
229         /**
230          * Sets analog signal type.
231          *
232          * <p>Default value is {@link #SIGNAL_TYPE_UNDEFINED}.
233          */
234         @NonNull
setSignalType(@ignalType int signalType)235         public Builder setSignalType(@SignalType int signalType) {
236             mSignalType = signalType;
237             return this;
238         }
239 
240         /**
241          * Sets Standard Interchange Format (SIF).
242          *
243          * <p>Default value is {@link #SIF_UNDEFINED}.
244          */
245         @NonNull
setSifStandard(@ifStandard int sifStandard)246         public Builder setSifStandard(@SifStandard int sifStandard) {
247             mSifStandard = sifStandard;
248             return this;
249         }
250 
251         /**
252          * Builds a {@link AnalogFrontendSettings} object.
253          */
254         @NonNull
build()255         public AnalogFrontendSettings build() {
256             return new AnalogFrontendSettings(mFrequency, mSignalType, mSifStandard);
257         }
258     }
259 }
260