1 /*
2  * Copyright (C) 2014 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 com.android.server.hdmi;
18 
19 import android.annotation.IntDef;
20 import android.annotation.StringDef;
21 import android.hardware.hdmi.HdmiDeviceInfo;
22 import android.hardware.tv.hdmi.connection.HpdSignal;
23 import android.hardware.tv.hdmi.earc.IEArcStatus;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * Defines constants related to HDMI-CEC protocol internal implementation. If a constant will be
30  * used in the public api, it should be located in {@link android.hardware.hdmi.HdmiControlManager}.
31  */
32 final class Constants {
33 
34     /** Logical address for TV */
35     public static final int ADDR_TV = 0;
36 
37     /** Logical address for recorder 1 */
38     public static final int ADDR_RECORDER_1 = 1;
39 
40     /** Logical address for recorder 2 */
41     public static final int ADDR_RECORDER_2 = 2;
42 
43     /** Logical address for tuner 1 */
44     public static final int ADDR_TUNER_1 = 3;
45 
46     /** Logical address for playback 1 */
47     public static final int ADDR_PLAYBACK_1 = 4;
48 
49     /** Logical address for audio system */
50     public static final int ADDR_AUDIO_SYSTEM = 5;
51 
52     /** Logical address for tuner 2 */
53     public static final int ADDR_TUNER_2 = 6;
54 
55     /** Logical address for tuner 3 */
56     public static final int ADDR_TUNER_3 = 7;
57 
58     /** Logical address for playback 2 */
59     public static final int ADDR_PLAYBACK_2 = 8;
60 
61     /** Logical address for recorder 3 */
62     public static final int ADDR_RECORDER_3 = 9;
63 
64     /** Logical address for tuner 4 */
65     public static final int ADDR_TUNER_4 = 10;
66 
67     /** Logical address for playback 3 */
68     public static final int ADDR_PLAYBACK_3 = 11;
69 
70     /** Logical address reserved for future usage */
71     public static final int ADDR_BACKUP_1 = 12;
72 
73     /** Logical address reserved for future usage */
74     public static final int ADDR_BACKUP_2 = 13;
75 
76     /** Logical address for TV other than the one assigned with {@link #ADDR_TV} */
77     public static final int ADDR_SPECIFIC_USE = 14;
78 
79     /** Logical address for devices to which address cannot be allocated */
80     public static final int ADDR_UNREGISTERED = 15;
81 
82     /** Logical address used in the destination address field for broadcast messages */
83     public static final int ADDR_BROADCAST = 15;
84 
85     /** Logical address used to indicate it is not initialized or invalid. */
86     public static final int ADDR_INVALID = HdmiDeviceInfo.ADDR_INVALID;
87 
88     /** Logical address used to indicate the source comes from internal device. */
89     public static final int ADDR_INTERNAL = HdmiDeviceInfo.ADDR_INTERNAL;
90 
91     @Retention(RetentionPolicy.SOURCE)
92     @IntDef({
93             MESSAGE_FEATURE_ABORT,
94             MESSAGE_IMAGE_VIEW_ON,
95             MESSAGE_TUNER_STEP_INCREMENT,
96             MESSAGE_TUNER_STEP_DECREMENT,
97             MESSAGE_TUNER_DEVICE_STATUS,
98             MESSAGE_GIVE_TUNER_DEVICE_STATUS,
99             MESSAGE_RECORD_ON,
100             MESSAGE_RECORD_STATUS,
101             MESSAGE_RECORD_OFF,
102             MESSAGE_TEXT_VIEW_ON,
103             MESSAGE_RECORD_TV_SCREEN,
104             MESSAGE_GIVE_DECK_STATUS,
105             MESSAGE_DECK_STATUS,
106             MESSAGE_SET_MENU_LANGUAGE,
107             MESSAGE_CLEAR_ANALOG_TIMER,
108             MESSAGE_SET_ANALOG_TIMER,
109             MESSAGE_TIMER_STATUS,
110             MESSAGE_STANDBY,
111             MESSAGE_PLAY,
112             MESSAGE_DECK_CONTROL,
113             MESSAGE_TIMER_CLEARED_STATUS,
114             MESSAGE_USER_CONTROL_PRESSED,
115             MESSAGE_USER_CONTROL_RELEASED,
116             MESSAGE_GIVE_OSD_NAME,
117             MESSAGE_SET_OSD_NAME,
118             MESSAGE_SET_OSD_STRING,
119             MESSAGE_SET_TIMER_PROGRAM_TITLE,
120             MESSAGE_SYSTEM_AUDIO_MODE_REQUEST,
121             MESSAGE_GIVE_AUDIO_STATUS,
122             MESSAGE_SET_SYSTEM_AUDIO_MODE,
123             MESSAGE_SET_AUDIO_VOLUME_LEVEL,
124             MESSAGE_REPORT_AUDIO_STATUS,
125             MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS,
126             MESSAGE_SYSTEM_AUDIO_MODE_STATUS,
127             MESSAGE_ROUTING_CHANGE,
128             MESSAGE_ROUTING_INFORMATION,
129             MESSAGE_ACTIVE_SOURCE,
130             MESSAGE_GIVE_PHYSICAL_ADDRESS,
131             MESSAGE_REPORT_PHYSICAL_ADDRESS,
132             MESSAGE_REQUEST_ACTIVE_SOURCE,
133             MESSAGE_SET_STREAM_PATH,
134             MESSAGE_DEVICE_VENDOR_ID,
135             MESSAGE_VENDOR_COMMAND,
136             MESSAGE_VENDOR_REMOTE_BUTTON_DOWN,
137             MESSAGE_VENDOR_REMOTE_BUTTON_UP,
138             MESSAGE_GIVE_DEVICE_VENDOR_ID,
139             MESSAGE_MENU_REQUEST,
140             MESSAGE_MENU_STATUS,
141             MESSAGE_GIVE_DEVICE_POWER_STATUS,
142             MESSAGE_REPORT_POWER_STATUS,
143             MESSAGE_GET_MENU_LANGUAGE,
144             MESSAGE_SELECT_ANALOG_SERVICE,
145             MESSAGE_SELECT_DIGITAL_SERVICE,
146             MESSAGE_SET_DIGITAL_TIMER,
147             MESSAGE_CLEAR_DIGITAL_TIMER,
148             MESSAGE_SET_AUDIO_RATE,
149             MESSAGE_INACTIVE_SOURCE,
150             MESSAGE_CEC_VERSION,
151             MESSAGE_GET_CEC_VERSION,
152             MESSAGE_VENDOR_COMMAND_WITH_ID,
153             MESSAGE_CLEAR_EXTERNAL_TIMER,
154             MESSAGE_SET_EXTERNAL_TIMER,
155             MESSAGE_REPORT_SHORT_AUDIO_DESCRIPTOR,
156             MESSAGE_REQUEST_SHORT_AUDIO_DESCRIPTOR,
157             MESSAGE_GIVE_FEATURES,
158             MESSAGE_REPORT_FEATURES,
159             MESSAGE_REQUEST_CURRENT_LATENCY,
160             MESSAGE_REPORT_CURRENT_LATENCY,
161             MESSAGE_INITIATE_ARC,
162             MESSAGE_REPORT_ARC_INITIATED,
163             MESSAGE_REPORT_ARC_TERMINATED,
164             MESSAGE_REQUEST_ARC_INITIATION,
165             MESSAGE_REQUEST_ARC_TERMINATION,
166             MESSAGE_TERMINATE_ARC,
167             MESSAGE_CDC_MESSAGE,
168             MESSAGE_ABORT,
169     })
170     public @interface FeatureOpcode {
171     }
172 
173     static final int MESSAGE_FEATURE_ABORT = 0x00;
174     static final int MESSAGE_IMAGE_VIEW_ON = 0x04;
175     static final int MESSAGE_TUNER_STEP_INCREMENT = 0x05;
176     static final int MESSAGE_TUNER_STEP_DECREMENT = 0x06;
177     static final int MESSAGE_TUNER_DEVICE_STATUS = 0x07;
178     static final int MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08;
179     static final int MESSAGE_RECORD_ON = 0x09;
180     static final int MESSAGE_RECORD_STATUS = 0x0A;
181     static final int MESSAGE_RECORD_OFF = 0x0B;
182     static final int MESSAGE_TEXT_VIEW_ON = 0x0D;
183     static final int MESSAGE_RECORD_TV_SCREEN = 0x0F;
184     static final int MESSAGE_GIVE_DECK_STATUS = 0x1A;
185     static final int MESSAGE_DECK_STATUS = 0x1B;
186     static final int MESSAGE_SET_MENU_LANGUAGE = 0x32;
187     static final int MESSAGE_CLEAR_ANALOG_TIMER = 0x33;
188     static final int MESSAGE_SET_ANALOG_TIMER = 0x34;
189     static final int MESSAGE_TIMER_STATUS = 0x35;
190     static final int MESSAGE_STANDBY = 0x36;
191     static final int MESSAGE_PLAY = 0x41;
192     static final int MESSAGE_DECK_CONTROL = 0x42;
193     static final int MESSAGE_TIMER_CLEARED_STATUS = 0x043;
194     static final int MESSAGE_USER_CONTROL_PRESSED = 0x44;
195     static final int MESSAGE_USER_CONTROL_RELEASED = 0x45;
196     static final int MESSAGE_GIVE_OSD_NAME = 0x46;
197     static final int MESSAGE_SET_OSD_NAME = 0x47;
198     static final int MESSAGE_SET_OSD_STRING = 0x64;
199     static final int MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67;
200     static final int MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70;
201     static final int MESSAGE_GIVE_AUDIO_STATUS = 0x71;
202     static final int MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72;
203     static final int MESSAGE_SET_AUDIO_VOLUME_LEVEL = 0x73;
204     static final int MESSAGE_REPORT_AUDIO_STATUS = 0x7A;
205     static final int MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D;
206     static final int MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E;
207     static final int MESSAGE_ROUTING_CHANGE = 0x80;
208     static final int MESSAGE_ROUTING_INFORMATION = 0x81;
209     static final int MESSAGE_ACTIVE_SOURCE = 0x82;
210     static final int MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83;
211     static final int MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84;
212     static final int MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85;
213     static final int MESSAGE_SET_STREAM_PATH = 0x86;
214     static final int MESSAGE_DEVICE_VENDOR_ID = 0x87;
215     static final int MESSAGE_VENDOR_COMMAND = 0x89;
216     static final int MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A;
217     static final int MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B;
218     static final int MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C;
219     static final int MESSAGE_MENU_REQUEST = 0x8D;
220     static final int MESSAGE_MENU_STATUS = 0x8E;
221     static final int MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F;
222     static final int MESSAGE_REPORT_POWER_STATUS = 0x90;
223     static final int MESSAGE_GET_MENU_LANGUAGE = 0x91;
224     static final int MESSAGE_SELECT_ANALOG_SERVICE = 0x92;
225     static final int MESSAGE_SELECT_DIGITAL_SERVICE = 0x93;
226     static final int MESSAGE_SET_DIGITAL_TIMER = 0x97;
227     static final int MESSAGE_CLEAR_DIGITAL_TIMER = 0x99;
228     static final int MESSAGE_SET_AUDIO_RATE = 0x9A;
229     static final int MESSAGE_INACTIVE_SOURCE = 0x9D;
230     static final int MESSAGE_CEC_VERSION = 0x9E;
231     static final int MESSAGE_GET_CEC_VERSION = 0x9F;
232     static final int MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0;
233     static final int MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1;
234     static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2;
235     static final int MESSAGE_REPORT_SHORT_AUDIO_DESCRIPTOR = 0xA3;
236     static final int MESSAGE_REQUEST_SHORT_AUDIO_DESCRIPTOR = 0xA4;
237     static final int MESSAGE_GIVE_FEATURES = 0xA5;
238     static final int MESSAGE_REPORT_FEATURES = 0xA6;
239     static final int MESSAGE_REQUEST_CURRENT_LATENCY = 0xA7;
240     static final int MESSAGE_REPORT_CURRENT_LATENCY = 0xA8;
241     static final int MESSAGE_INITIATE_ARC = 0xC0;
242     static final int MESSAGE_REPORT_ARC_INITIATED = 0xC1;
243     static final int MESSAGE_REPORT_ARC_TERMINATED = 0xC2;
244     static final int MESSAGE_REQUEST_ARC_INITIATION = 0xC3;
245     static final int MESSAGE_REQUEST_ARC_TERMINATION = 0xC4;
246     static final int MESSAGE_TERMINATE_ARC = 0xC5;
247     static final int MESSAGE_CDC_MESSAGE = 0xF8;
248     static final int MESSAGE_ABORT = 0xFF;
249 
250     static final int VENDOR_ID_UNKNOWN = HdmiDeviceInfo.VENDOR_ID_UNKNOWN;
251 
252     static final int TRUE = 1;
253     static final int FALSE = 0;
254 
255     @Retention(RetentionPolicy.SOURCE)
256     @IntDef({
257             NOT_HANDLED,
258             HANDLED,
259             ABORT_UNRECOGNIZED_OPCODE,
260             ABORT_NOT_IN_CORRECT_MODE,
261             ABORT_CANNOT_PROVIDE_SOURCE,
262             ABORT_INVALID_OPERAND,
263             ABORT_REFUSED,
264             ABORT_UNABLE_TO_DETERMINE,
265     })
266     public @interface HandleMessageResult {}
267 
268     @Retention(RetentionPolicy.SOURCE)
269     @IntDef({
270         ABORT_UNRECOGNIZED_OPCODE,
271         ABORT_NOT_IN_CORRECT_MODE,
272         ABORT_CANNOT_PROVIDE_SOURCE,
273         ABORT_INVALID_OPERAND,
274         ABORT_REFUSED,
275         ABORT_UNABLE_TO_DETERMINE,
276     })
277     public @interface AbortReason {}
278 
279     // Indicates that a message was not handled, but could be handled by another local device.
280     // If no local devices handle the message, we send <Feature Abort>[Unrecognized Opcode].
281     static final int NOT_HANDLED = -2;
282     // Indicates that a message has been handled successfully; no feature abort needed.
283     static final int HANDLED = -1;
284     // Constants related to operands of HDMI CEC commands.
285     // Refer to CEC Table 29 in HDMI Spec v1.4b.
286     // [Abort Reason]
287     static final int ABORT_UNRECOGNIZED_OPCODE = 0;
288     static final int ABORT_NOT_IN_CORRECT_MODE = 1;
289     static final int ABORT_CANNOT_PROVIDE_SOURCE = 2;
290     static final int ABORT_INVALID_OPERAND = 3;
291     static final int ABORT_REFUSED = 4;
292     static final int ABORT_UNABLE_TO_DETERMINE = 5;
293 
294     // [Audio Status]
295     static final int SYSTEM_AUDIO_STATUS_OFF = 0;
296     static final int SYSTEM_AUDIO_STATUS_ON = 1;
297 
298     // [Menu State]
299     static final int MENU_STATE_ACTIVATED = 0;
300     static final int MENU_STATE_DEACTIVATED = 1;
301 
302     // Audio Format Codes
303     // Refer to CEA Standard (CEA-861-D), Table 37 Audio Format Codes.
304     @Retention(RetentionPolicy.SOURCE)
305     @IntDef({
306         AUDIO_CODEC_NONE,
307         AUDIO_CODEC_LPCM,
308         AUDIO_CODEC_DD,
309         AUDIO_CODEC_MPEG1,
310         AUDIO_CODEC_MP3,
311         AUDIO_CODEC_MPEG2,
312         AUDIO_CODEC_AAC,
313         AUDIO_CODEC_DTS,
314         AUDIO_CODEC_ATRAC,
315         AUDIO_CODEC_ONEBITAUDIO,
316         AUDIO_CODEC_DDP,
317         AUDIO_CODEC_DTSHD,
318         AUDIO_CODEC_TRUEHD,
319         AUDIO_CODEC_DST,
320         AUDIO_CODEC_WMAPRO,
321         AUDIO_CODEC_MAX,
322     })
323     public @interface AudioCodec {}
324 
325     static final int AUDIO_CODEC_NONE = 0x0;
326     static final int AUDIO_CODEC_LPCM = 0x1; // Support LPCMs
327     static final int AUDIO_CODEC_DD = 0x2; // Support DD
328     static final int AUDIO_CODEC_MPEG1 = 0x3; // Support MPEG1
329     static final int AUDIO_CODEC_MP3 = 0x4; // Support MP3
330     static final int AUDIO_CODEC_MPEG2 = 0x5; // Support MPEG2
331     static final int AUDIO_CODEC_AAC = 0x6; // Support AAC
332     static final int AUDIO_CODEC_DTS = 0x7; // Support DTS
333     static final int AUDIO_CODEC_ATRAC = 0x8; // Support ATRAC
334     static final int AUDIO_CODEC_ONEBITAUDIO = 0x9; // Support One-Bit Audio
335     static final int AUDIO_CODEC_DDP = 0xA; // Support DDP
336     static final int AUDIO_CODEC_DTSHD = 0xB; // Support DTSHD
337     static final int AUDIO_CODEC_TRUEHD = 0xC; // Support MLP/TRUE-HD
338     static final int AUDIO_CODEC_DST = 0xD; // Support DST
339     static final int AUDIO_CODEC_WMAPRO = 0xE; // Support WMA-Pro
340     static final int AUDIO_CODEC_MAX = 0xF;
341 
342     static final int AUDIO_FORMAT_MASK = 0b0111_1000;
343 
344     @StringDef({
345         AUDIO_DEVICE_ARC_IN,
346         AUDIO_DEVICE_SPDIF,
347     })
348     public @interface AudioDevice {}
349 
350     static final String AUDIO_DEVICE_ARC_IN = "ARC_IN";
351     static final String AUDIO_DEVICE_SPDIF = "SPDIF";
352 
353     // Bit mask used to get the routing path of the top level device.
354     // When &'d with the path 1.2.2.0 (0x1220), for instance, gives 1.0.0.0.
355     static final int ROUTING_PATH_TOP_MASK = 0xF000;
356     static final int ROUTING_PATH_TOP_SHIFT = 12;
357 
358     static final int INVALID_PORT_ID = HdmiDeviceInfo.PORT_INVALID;
359     static final int INVALID_PHYSICAL_ADDRESS = HdmiDeviceInfo.PATH_INVALID;
360     static final int TV_PHYSICAL_ADDRESS = HdmiDeviceInfo.PATH_INTERNAL;
361 
362     // The relationship from one path (physical address) to another.
363     @IntDef({
364             PATH_RELATIONSHIP_UNKNOWN,
365             PATH_RELATIONSHIP_DIFFERENT_BRANCH,
366             PATH_RELATIONSHIP_ANCESTOR,
367             PATH_RELATIONSHIP_DESCENDANT,
368             PATH_RELATIONSHIP_SIBLING,
369             PATH_RELATIONSHIP_SAME
370     })
371     @interface PathRelationship {}
372 
373     // One or both of the paths is invalid
374     static final int PATH_RELATIONSHIP_UNKNOWN = 0;
375     // None of the relationships below holds
376     static final int PATH_RELATIONSHIP_DIFFERENT_BRANCH = 1;
377     // A path is either the TV, or between the TV and another path
378     static final int PATH_RELATIONSHIP_ANCESTOR = 2;
379     // A path is located somewhere below another path
380     static final int PATH_RELATIONSHIP_DESCENDANT = 3;
381     // A path has the same parent as another path
382     static final int PATH_RELATIONSHIP_SIBLING = 4;
383     // A path is equal to another path
384     static final int PATH_RELATIONSHIP_SAME = 5;
385 
386     // Strategy for device polling.
387     // Should use "OR(|) operation of POLL_STRATEGY_XXX and POLL_ITERATION_XXX.
388     static final int POLL_STRATEGY_MASK = 0x3; // first and second bit.
389     static final int POLL_STRATEGY_REMOTES_DEVICES = 0x1;
390     static final int POLL_STRATEGY_SYSTEM_AUDIO = 0x2;
391 
392     static final int POLL_ITERATION_STRATEGY_MASK = 0x30000; // first and second bit.
393     static final int POLL_ITERATION_IN_ORDER = 0x10000;
394     static final int POLL_ITERATION_REVERSE_ORDER = 0x20000;
395 
396     static final int UNKNOWN_VOLUME = -1;
397 
398     // This constant is used in two operands in the CEC spec.
399     //
400     // CEC 1.4: [Audio Volume Status] (part of [Audio Status]) - operand for <Report Audio Status>
401     // Indicates that the current audio volume status is unknown.
402     //
403     // CEC 2.1a: [Audio Volume Level] - operand for <Set Audio Volume Level>
404     // Part of the Absolute Volume Control feature. Indicates that no change shall be made to the
405     // volume level of the recipient. This allows <Set Audio Volume Level> to be sent to determine
406     // whether the recipient supports Absolute Volume Control.
407     static final int AUDIO_VOLUME_STATUS_UNKNOWN = 0x7F;
408 
409     // States of property PROPERTY_SYSTEM_AUDIO_CONTROL_ON_POWER_ON
410     // to decide if turn on the system audio control when power on the device
411     @IntDef({
412         ALWAYS_SYSTEM_AUDIO_CONTROL_ON_POWER_ON,
413         USE_LAST_STATE_SYSTEM_AUDIO_CONTROL_ON_POWER_ON,
414         NEVER_SYSTEM_AUDIO_CONTROL_ON_POWER_ON
415     })
416     @interface SystemAudioControlOnPowerOn {}
417 
418     static final int ALWAYS_SYSTEM_AUDIO_CONTROL_ON_POWER_ON = 0;
419     static final int USE_LAST_STATE_SYSTEM_AUDIO_CONTROL_ON_POWER_ON = 1;
420     static final int NEVER_SYSTEM_AUDIO_CONTROL_ON_POWER_ON = 2;
421 
422     // Port id to record local active port for Routing Control features
423     // They are used to map to corresponding Inputs
424     // Current interface is only implemented for specific device.
425     // Developers can add more port number and map them to corresponding inputs on demand.
426     @IntDef({
427         CEC_SWITCH_HOME,
428         CEC_SWITCH_HDMI1,
429         CEC_SWITCH_HDMI2,
430         CEC_SWITCH_HDMI3,
431         CEC_SWITCH_HDMI4,
432         CEC_SWITCH_HDMI5,
433         CEC_SWITCH_HDMI6,
434         CEC_SWITCH_HDMI7,
435         CEC_SWITCH_HDMI8,
436         CEC_SWITCH_ARC,
437         CEC_SWITCH_BLUETOOTH,
438         CEC_SWITCH_OPTICAL,
439         CEC_SWITCH_AUX
440     })
441     @interface LocalActivePort {}
442     static final int CEC_SWITCH_HOME = 0;
443     static final int CEC_SWITCH_HDMI1 = 1;
444     static final int CEC_SWITCH_HDMI2 = 2;
445     static final int CEC_SWITCH_HDMI3 = 3;
446     static final int CEC_SWITCH_HDMI4 = 4;
447     static final int CEC_SWITCH_HDMI5 = 5;
448     static final int CEC_SWITCH_HDMI6 = 6;
449     static final int CEC_SWITCH_HDMI7 = 7;
450     static final int CEC_SWITCH_HDMI8 = 8;
451     static final int CEC_SWITCH_ARC = 17;
452     static final int CEC_SWITCH_BLUETOOTH = 18;
453     static final int CEC_SWITCH_OPTICAL = 19;
454     static final int CEC_SWITCH_AUX = 20;
455     static final int CEC_SWITCH_PORT_MAX = 21;
456 
457     static final String PROPERTY_PREFERRED_ADDRESS_AUDIO_SYSTEM =
458             "persist.sys.hdmi.addr.audiosystem";
459     static final String PROPERTY_PREFERRED_ADDRESS_PLAYBACK = "persist.sys.hdmi.addr.playback";
460     static final String PROPERTY_PREFERRED_ADDRESS_TV = "persist.sys.hdmi.addr.tv";
461 
462     // Set to false to allow playback device to go to suspend mode even
463     // when it's an active source. True by default.
464     static final String PROPERTY_KEEP_AWAKE = "persist.sys.hdmi.keep_awake";
465 
466     // TODO(UI): Set this from UI to decide if turn on System Audio Mode when power on the device
467     /**
468      * Property to decide if turn on the system audio control when power on the device.
469      *
470      * <p>Default is always turn on. State must be a valid {@link SystemAudioControlOnPowerOn} int.
471      */
472     static final String PROPERTY_SYSTEM_AUDIO_CONTROL_ON_POWER_ON =
473             "persist.sys.hdmi.system_audio_control_on_power_on";
474 
475     /**
476      * Property to record last state of system audio control before device powered off.
477      * <p>When {@link #PROPERTY_SYSTEM_AUDIO_CONTROL_ON_POWER_ON} is set to
478      * {@link #USE_LAST_STATE_SYSTEM_AUDIO_CONTROL_ON_POWER_ON}, restoring this state on power on.
479      * <p>State must be true or false. Default true.
480      */
481     static final String PROPERTY_LAST_SYSTEM_AUDIO_CONTROL =
482             "persist.sys.hdmi.last_system_audio_control";
483 
484     /**
485      * Property to indicate if device supports ARC or not
486      * <p>Default is true.
487      */
488     static final String PROPERTY_ARC_SUPPORT =
489             "persist.sys.hdmi.property_arc_support";
490 
491     /**
492      * Property to save the audio port to switch to when system audio control is on.
493      * <P>Audio system should switch to this port when cec active source is not its child in the tree
494      * or is not itself.
495      *
496      * <p>Default is ARC port.
497      */
498     static final String PROPERTY_SYSTEM_AUDIO_MODE_AUDIO_PORT =
499             "persist.sys.hdmi.property_sytem_audio_mode_audio_port";
500 
501     /**
502      * Property to strip local audio of amplifier and use local speaker
503      * when TV does not support system audio mode.
504      *
505      * <p>This property applies to device with both audio system/playback types.
506      * <p>True means using local speaker when TV does not support system audio.
507      * <p>False means passing audio to TV. Default is true.
508      */
509     static final String PROPERTY_STRIP_AUDIO_TV_NO_SYSTEM_AUDIO =
510         "persist.sys.hdmi.property_strip_audio_tv_no_system_audio";
511 
512     static final int RECORDING_TYPE_DIGITAL_RF = 1;
513     static final int RECORDING_TYPE_ANALOGUE_RF = 2;
514     static final int RECORDING_TYPE_EXTERNAL_PHYSICAL_ADDRESS = 3;
515     static final int RECORDING_TYPE_OWN_SOURCE = 4;
516 
517     // Definitions used for setOption(). These should be in sync with the definition
518     // in hardware/libhardware/include/hardware/mhl.h.
519 
520     // If set to disabled, TV does not switch ports when mobile device is connected.
521     static final int OPTION_MHL_INPUT_SWITCHING = 101;
522 
523     // If set to enabled, TV disables power charging for mobile device.
524     static final int OPTION_MHL_POWER_CHARGE = 102;
525 
526     // If set to disabled, all MHL commands are discarded.
527     static final int OPTION_MHL_ENABLE = 103;
528 
529     // If set to disabled, system service yields control of MHL to sub-microcontroller.
530     // If enabled, it takes the control back.
531     static final int OPTION_MHL_SERVICE_CONTROL = 104;
532 
533     static final int DISABLED = 0;
534     static final int ENABLED = 1;
535 
536     static final int ALL_DEVICE_TYPES_TV = 7;
537     static final int ALL_DEVICE_TYPES_RECORDER = 6;
538     static final int ALL_DEVICE_TYPES_TUNER = 5;
539     static final int ALL_DEVICE_TYPES_PLAYBACK = 4;
540     static final int ALL_DEVICE_TYPES_AUDIO_SYSTEM = 3;
541     static final int ALL_DEVICE_TYPES_SWITCH = 2;
542     @IntDef({
543             ALL_DEVICE_TYPES_TV,
544             ALL_DEVICE_TYPES_RECORDER,
545             ALL_DEVICE_TYPES_TUNER,
546             ALL_DEVICE_TYPES_PLAYBACK,
547             ALL_DEVICE_TYPES_AUDIO_SYSTEM,
548             ALL_DEVICE_TYPES_SWITCH
549     })
550     @interface DeviceType {}
551 
552     static final int DEVICE_FEATURE_TV_SUPPORTS_RECORD_TV_SCREEN = 6;
553     static final int DEVICE_FEATURE_TV_SUPPORTS_SET_OSD_STRING = 5;
554     static final int DEVICE_FEATURE_SUPPORTS_DECK_CONTROL = 4;
555     static final int DEVICE_FEATURE_SUPPORTS_SET_AUDIO_RATE = 3;
556     static final int DEVICE_FEATURE_SINK_SUPPORTS_ARC_TX = 2;
557     static final int DEVICE_FEATURE_SOURCE_SUPPORTS_ARC_RX = 1;
558     @IntDef({
559             DEVICE_FEATURE_TV_SUPPORTS_RECORD_TV_SCREEN,
560             DEVICE_FEATURE_TV_SUPPORTS_SET_OSD_STRING,
561             DEVICE_FEATURE_SUPPORTS_DECK_CONTROL,
562             DEVICE_FEATURE_SUPPORTS_SET_AUDIO_RATE,
563             DEVICE_FEATURE_SINK_SUPPORTS_ARC_TX,
564             DEVICE_FEATURE_SOURCE_SUPPORTS_ARC_RX
565     })
566     @interface DeviceFeature {}
567 
568     static final int RC_PROFILE_TV = 0;
569     static final int RC_PROFILE_SOURCE = 1;
570     @IntDef({
571             RC_PROFILE_TV,
572             RC_PROFILE_SOURCE
573     })
574     @interface RcProfile {}
575 
576     static final int RC_PROFILE_TV_NONE = 0x0;
577     static final int RC_PROFILE_TV_ONE = 0x2;
578     static final int RC_PROFILE_TV_TWO = 0x6;
579     static final int RC_PROFILE_TV_THREE = 0xA;
580     static final int RC_PROFILE_TV_FOUR = 0xE;
581     @IntDef({
582             RC_PROFILE_TV_NONE,
583             RC_PROFILE_TV_ONE,
584             RC_PROFILE_TV_TWO,
585             RC_PROFILE_TV_THREE,
586             RC_PROFILE_TV_FOUR
587     })
588     @interface RcProfileTv {}
589 
590     static final int RC_PROFILE_SOURCE_HANDLES_ROOT_MENU = 4;
591     static final int RC_PROFILE_SOURCE_HANDLES_SETUP_MENU = 3;
592     static final int RC_PROFILE_SOURCE_HANDLES_CONTENTS_MENU = 2;
593     static final int RC_PROFILE_SOURCE_HANDLES_TOP_MENU = 1;
594     static final int RC_PROFILE_SOURCE_HANDLES_MEDIA_CONTEXT_SENSITIVE_MENU = 0;
595     @IntDef({
596             RC_PROFILE_SOURCE_HANDLES_ROOT_MENU,
597             RC_PROFILE_SOURCE_HANDLES_SETUP_MENU,
598             RC_PROFILE_SOURCE_HANDLES_CONTENTS_MENU,
599             RC_PROFILE_SOURCE_HANDLES_TOP_MENU,
600             RC_PROFILE_SOURCE_HANDLES_MEDIA_CONTEXT_SENSITIVE_MENU
601     })
602     @interface RcProfileSource {}
603 
604     static final int HDMI_EARC_STATUS_UNKNOWN = -1;
605     static final int HDMI_EARC_STATUS_IDLE = IEArcStatus.IDLE; // IDLE1
606     static final int HDMI_EARC_STATUS_EARC_PENDING =
607             IEArcStatus.EARC_PENDING; // DISC1 and DISC2
608     static final int HDMI_EARC_STATUS_ARC_PENDING = IEArcStatus.ARC_PENDING; // IDLE2 for ARC
609     static final int HDMI_EARC_STATUS_EARC_CONNECTED =
610             IEArcStatus.EARC_CONNECTED; // eARC connected
611 
612     @IntDef({
613             HDMI_EARC_STATUS_UNKNOWN,
614             HDMI_EARC_STATUS_IDLE,
615             HDMI_EARC_STATUS_EARC_PENDING,
616             HDMI_EARC_STATUS_ARC_PENDING,
617             HDMI_EARC_STATUS_EARC_CONNECTED
618             })
619     @interface EarcStatus {}
620 
621     static final int HDMI_HPD_TYPE_PHYSICAL =
622             HpdSignal.HDMI_HPD_PHYSICAL; // Default. Physical hotplug signal.
623     static final int HDMI_HPD_TYPE_STATUS_BIT =
624             HpdSignal.HDMI_HPD_STATUS_BIT; // HDMI_HPD status bit.
625 
626     @IntDef({
627             HDMI_HPD_TYPE_PHYSICAL,
628             HDMI_HPD_TYPE_STATUS_BIT
629     })
630     @interface HpdSignalType {}
631 
632     static final String DEVICE_CONFIG_FEATURE_FLAG_SOUNDBAR_MODE = "enable_soundbar_mode";
633     static final String DEVICE_CONFIG_FEATURE_FLAG_ENABLE_EARC_TX = "enable_earc_tx";
634     static final String DEVICE_CONFIG_FEATURE_FLAG_TRANSITION_ARC_TO_EARC_TX =
635             "transition_arc_to_earc_tx";
636     // Name is abbreviated slightly to avoid line length issues
637     static final String DEVICE_CONFIG_FEATURE_FLAG_TV_NUMERIC_SOUNDBAR_VOLUME_UI =
638             "enable_numeric_soundbar_volume_ui_on_tv";
639     @StringDef({
640             DEVICE_CONFIG_FEATURE_FLAG_SOUNDBAR_MODE,
641             DEVICE_CONFIG_FEATURE_FLAG_ENABLE_EARC_TX,
642             DEVICE_CONFIG_FEATURE_FLAG_TRANSITION_ARC_TO_EARC_TX,
643             DEVICE_CONFIG_FEATURE_FLAG_TV_NUMERIC_SOUNDBAR_VOLUME_UI
644     })
645     @interface FeatureFlag {}
646 
Constants()647     private Constants() {
648         /* cannot be instantiated */
649     }
650 }
651