summaryrefslogtreecommitdiff
path: root/broadcastradio/1.1/types.hal
blob: 8b8fc6fddee25874ff0a42869e4b557fb2fcb0e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/**
 * Copyright 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.broadcastradio@1.1;

import @1.0::types;

typedef @1.0::Result Result;

enum ProgramListResult : Result {
    NOT_READY,
    NOT_STARTED,
    UNAVAILABLE,
};

/**
 * Extra flags for program information.
 */
enum ProgramInfoFlags : uint32_t {
    /**
     * Set when the program is currently playing live stream.
     * This may result in a slightly altered reception parameters,
     * usually targetted at reduced latency.
     */
    LIVE = 1 << 0,

    /**
     * Radio stream is not playing, ie. due to bad reception conditions or
     * buffering. In this state volume knob MAY be disabled to prevent user
     * increasing volume too much.
     */
    MUTED = 1 << 1,

    /**
     * Station broadcasts traffic information regularly,
     * but not necessarily right now.
     */
    TRAFFIC_PROGRAM = 1 << 2,

    /**
     * Station is broadcasting traffic information at the very moment.
     */
    TRAFFIC_ANNOUNCEMENT = 1 << 3,
};

/**
 * A key-value pair for vendor-specific information to be passed as-is through
 * Android framework to the front-end application.
 */
struct VendorKeyValue {
    /**
     * Key must be prefixed with unique vendor Java-style namespace,
     * eg. 'com.somecompany.parameter1'.
     */
    string key;

    /**
     * Value must be passed through the framework without any changes.
     * Format of this string can vary across vendors.
     */
    string value;
};

struct Properties {
    @1.0::Properties base;

    /**
     * The hardware supports background scanning in general. At the given time
     * it may not be available though, see startBackgroundScan.
     */
    bool supportsBackgroundScanning;

    /**
     * A list of supported ProgramType values.
     *
     * If a program type is supported by radio module, it means it can tune
     * to ProgramSelector of a given type.
     *
     * Support for VENDOR program type does not guarantee compatibility, as
     * other module properties (implementor, product, version) must be checked.
     */
    vec<uint32_t> supportedProgramTypes;

    /**
     * A list of supported IdentifierType values.
     *
     * If an identifier is supported by radio module, it means it can use it for
     * tuning to ProgramSelector with either primary or secondary Identifier of
     * a given type.
     *
     * Support for VENDOR identifier type does not guarantee compatibility, as
     * other module properties (implementor, product, version) must be checked.
     */
    vec<uint32_t> supportedIdentifierTypes;

    /**
     * Vendor-specific information.
     *
     * It may be used for extra features, not supported by the platform,
     * for example: com.me.preset-slots=6; com.me.ultra-hd-capable=false.
     */
    vec<VendorKeyValue> vendorInfo;
};

/**
 * Type of modulation.
 *
 * Used as a value for DRMO_MODULATION IdentifierType.
 */
enum Modulation : uint32_t {
    AM = 1,
    FM,
};

/**
 * Type of a radio technology.
 *
 * VENDOR program types must be opaque to the framework.
 *
 * There are multiple VENDOR program types just to make vendor implementation
 * easier with multiple properitary radio technologies. They are treated the
 * same by the framework.
 *
 * All other values are reserved for future use.
 * Values not matching any enumerated constant must be ignored.
 */
enum ProgramType : uint32_t {
    AM = 1,  // analogue AM radio (with or without RDS)
    FM,      // analogue FM radio (with or without RDS)
    AM_HD,   // AM HD Radio
    FM_HD,   // FM HD Radio
    DAB,     // Digital audio broadcasting
    DRMO,    // Digital Radio Mondiale
    SXM,     // SiriusXM Satellite Radio

    // Vendor-specific, not synced across devices.
    VENDOR_START = 1000,
    VENDOR_END = 1999,
};

/**
 * Type of program identifier component.
 *
 * It MUST match the radio technology for primary ID but does not have to match
 * it for secondary IDs. For example, a satellite program may set AM/FM fallback
 * frequency, if a station broadcasts both via satellite and AM/FM.
 *
 * VENDOR identifier types must be opaque to the framework.
 *
 * The value format for each (but VENDOR_PRIMARY) identifier is strictly defined
 * to maintain interoperability between devices made by different vendors.
 *
 * All other values are reserved for future use.
 * Values not matching any enumerated constant must be ignored.
 */
enum IdentifierType : uint32_t {
    AMFM_FREQUENCY = 1,  // kHz
    RDS_PI,              // 16bit

    /**
     * 64bit compound primary identifier for HD Radio.
     *
     * Consists of (from the LSB):
     * - 32bit: Station ID number;
     * - 4bit: HD_SUBCHANNEL;
     * - 18bit: AMFM_FREQUENCY.
     * The remaining bits should be set to zeros when writing on the chip side
     * and ignored when read.
     */
    HD_STATION_ID_EXT,

    /**
     * HD Radio subchannel - a value of range 0-7.
     *
     * The subchannel index is 0-based (where 0 is MPS and 1..7 are SPS),
     * as opposed to HD Radio standard (where it's 1-based).
     */
    HD_SUBCHANNEL,

    /**
     * 24bit compound primary identifier for DAB.
     *
     * Consists of (from the LSB):
     * - 16bit: SId;
     * - 8bit: ECC code.
     * The remaining bits should be set to zeros when writing on the chip side
     * and ignored when read.
     */
    DAB_SIDECC,

    DAB_ENSEMBLE,     // 16bit
    DAB_SCID,         // 12bit
    DAB_FREQUENCY,    // kHz
    DRMO_SERVICE_ID,  // 24bit
    DRMO_FREQUENCY,   // kHz
    DRMO_MODULATION,  // Modulation enum
    SXM_SERVICE_ID,   // 32bit
    SXM_CHANNEL,      // 0-999 range

    /**
     * Primary identifier for vendor-specific radio technology.
     * The value format is determined by a vendor.
     *
     * It must not be used in any other programType than corresponding VENDOR
     * type between VENDOR_START and VENDOR_END (eg. identifier type 1015 must
     * not be used in any program type other than 1015).
     */
    VENDOR_PRIMARY_START = ProgramType:VENDOR_START,
    VENDOR_PRIMARY_END = ProgramType:VENDOR_END,
};

/**
 * A single program identifier component, eg. frequency or channel ID.
 *
 * The uint32_t type field maps to IdentifierType enum. It's not straight,
 * because the enum may be extended in future versions of the HAL. Values out of
 * the enum range must not be used when writing and ignored when reading.
 *
 * The uint64_t value field holds the value in format described in comments for
 * IdentifierType enum.
 */
struct ProgramIdentifier {
    uint32_t type;  // IdentifierType
    uint64_t value;
};

/**
 * A set of identifiers necessary to tune to a given station.
 *
 * This can hold various identifiers, like
 * - AM/FM frequency
 * - HD Radio subchannel
 * - DAB channel info
 *
 * The uint32_t programType field maps to ProgramType enum. It's not straight,
 * because the enum may be extended in future versions of the HAL. Values out of
 * the enum range must not be used when writing and ignored when reading.
 *
 * The primary ID uniquely identifies a station and can be used for equality
 * check. The secondary IDs are supplementary and can speed up tuning process,
 * but the primary ID is sufficient (ie. after a full band scan).
 *
 * Two selectors with different secondary IDs, but the same primary ID are
 * considered equal. In particular, secondary IDs vector may get updated for
 * an entry on the program list (ie. when a better frequency for a given
 * station is found).
 *
 * The primaryId of a given programType MUST be of a specific type:
 * - AM, FM: RDS_PI if the station broadcasts RDS, AMFM_FREQUENCY otherwise;
 * - AM_HD, FM_HD: HD_STATION_ID_EXT;
 * - DAB: DAB_SIDECC;
 * - DRMO: DRMO_SERVICE_ID;
 * - SXM: SXM_SERVICE_ID;
 * - VENDOR: VENDOR_PRIMARY.
 */
struct ProgramSelector {
    uint32_t programType;  // ProgramType
    ProgramIdentifier primaryId;  // uniquely identifies a station
    vec<ProgramIdentifier> secondaryIds;

    /**
     * Opaque vendor-specific identifiers, to be passed to front-end
     * without changes.
     *
     * The order is meaningful, ie. the first element may be defined as
     * frequency, second as the subchannel etc.
     *
     * The vector is not serialized (either locally or to the cloud),
     * unless it's a VENDOR program type.
     */
    vec<uint64_t> vendorIds;
};

/**
 * Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
 * Contains information on currently tuned channel.
 */
struct ProgramInfo {
    @1.0::ProgramInfo base;

    ProgramSelector selector;

    bitfield<ProgramInfoFlags> flags;

    /**
     * Vendor-specific information.
     *
     * It may be used for extra features, not supported by the platform,
     * for example: paid-service=true; bitrate=320kbps.
     */
    vec<VendorKeyValue> vendorInfo;
};