1 /*
2  * Copyright (C) 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.hdmicec.cts;
18 
19 import androidx.annotation.IntDef;
20 
21 import java.io.File;
22 
23 public final class HdmiCecConstants {
24 
HdmiCecConstants()25     private HdmiCecConstants() {}
26 
27     /** @deprecated not used anymore **/
28     @Deprecated
29     public static final String PHYSICAL_ADDRESS_NAME = "cec-phy-addr";
30     public static final int REBOOT_TIMEOUT = 60000;
31     public static final int TIMEOUT_CEC_REINIT_SECONDS = 5;
32     public static final int TIMEOUT_SAFETY_MS = 500;
33     public static final long TIMEOUT_UI_AND_STANDBY_AFTER_ACTIVE_SOURCE_LOST_SECONDS = 35;
34 
35     public static final int INVALID_VENDOR_ID = 0xFFFFFF;
36 
37     // Standard delay to allow the DUT to react to a CEC message or ADB command
38     public static final int DEVICE_WAIT_TIME_SECONDS = 5;
39     public static final int DEVICE_WAIT_TIME_MS = 5000;
40     public static final int MAX_SLEEP_TIME_SECONDS = 8;
41     public static final int SLEEP_TIMESTEP_SECONDS = 1;
42     public static final int SLEEP_TIME_DELAY_SECONDS = 2;
43     public static final int DEFAULT_PHYSICAL_ADDRESS = 0x1000;
44     public static final int TV_PHYSICAL_ADDRESS = 0x0000;
45     public static final int PHYSICAL_ADDRESS_LENGTH = 4; /* Num nibbles in CEC message */
46 
47     public static final int CEC_KEYCODE_SELECT = 0x00;
48     public static final int CEC_KEYCODE_UP = 0x01;
49     public static final int CEC_KEYCODE_DOWN = 0x02;
50     public static final int CEC_KEYCODE_LEFT = 0x03;
51     public static final int CEC_KEYCODE_RIGHT = 0x04;
52     public static final int CEC_KEYCODE_ROOT_MENU = 0x09;
53     public static final int CEC_KEYCODE_SETUP_MENU = 0x0A;
54     public static final int CEC_KEYCODE_CONTENTS_MENU = 0x0B;
55     public static final int CEC_KEYCODE_BACK = 0x0D;
56     public static final int CEC_KEYCODE_MEDIA_TOP_MENU = 0x10;
57     public static final int CEC_KEYCODE_MEDIA_CONTEXT_SENSITIVE_MENU = 0x11;
58     public static final int CEC_KEYCODE_NUMBER_0_OR_NUMBER_10 = 0x20;
59     public static final int CEC_KEYCODE_NUMBERS_1 = 0x21;
60     public static final int CEC_KEYCODE_NUMBERS_2 = 0x22;
61     public static final int CEC_KEYCODE_NUMBERS_3 = 0x23;
62     public static final int CEC_KEYCODE_NUMBERS_4 = 0x24;
63     public static final int CEC_KEYCODE_NUMBERS_5 = 0x25;
64     public static final int CEC_KEYCODE_NUMBERS_6 = 0x26;
65     public static final int CEC_KEYCODE_NUMBERS_7 = 0x27;
66     public static final int CEC_KEYCODE_NUMBERS_8 = 0x28;
67     public static final int CEC_KEYCODE_NUMBERS_9 = 0x29;
68     public static final int CEC_KEYCODE_CHANNEL_UP = 0x30;
69     public static final int CEC_KEYCODE_CHANNEL_DOWN = 0x31;
70     public static final int CEC_KEYCODE_PREVIOUS_CHANNEL = 0x32;
71     public static final int CEC_KEYCODE_DISPLAY_INFORMATION = 0x35;
72     public static final int CEC_KEYCODE_POWER = 0x40;
73     public static final int CEC_KEYCODE_VOLUME_UP = 0x41;
74     public static final int CEC_KEYCODE_VOLUME_DOWN = 0x42;
75     public static final int CEC_KEYCODE_MUTE = 0x43;
76     public static final int CEC_KEYCODE_PLAY = 0x44;
77     public static final int CEC_KEYCODE_STOP = 0x45;
78     public static final int CEC_KEYCODE_PAUSE = 0x46;
79     public static final int CEC_KEYCODE_RECORD = 0x47;
80     public static final int CEC_KEYCODE_REWIND = 0x48;
81     public static final int CEC_KEYCODE_FAST_FORWARD = 0x49;
82     public static final int CEC_KEYCODE_EJECT = 0x4A;
83     public static final int CEC_KEYCODE_FORWARD = 0x4B;
84     public static final int CEC_KEYCODE_BACKWARD = 0x4C;
85     public static final int CEC_KEYCODE_POWER_TOGGLE_FUNCTION = 0x6B;
86     public static final int CEC_KEYCODE_POWER_OFF_FUNCTION = 0x6C;
87     public static final int CEC_KEYCODE_POWER_ON_FUNCTION = 0x6D;
88     public static final int CEC_KEYCODE_F1_BLUE = 0x71;
89     public static final int CEC_KEYCODE_F2_RED = 0x72;
90     public static final int CEC_KEYCODE_F3_GREEN = 0x73;
91     public static final int CEC_KEYCODE_F4_YELLOW = 0x74;
92     public static final int CEC_KEYCODE_DATA = 0x76;
93 
94     public static final int UNRECOGNIZED_OPCODE = 0x0;
95 
96     @IntDef(
97             value = {
98                 CEC_DEVICE_TYPE_UNKNOWN,
99                 CEC_DEVICE_TYPE_TV,
100                 CEC_DEVICE_TYPE_RECORDER,
101                 CEC_DEVICE_TYPE_RESERVED,
102                 CEC_DEVICE_TYPE_TUNER,
103                 CEC_DEVICE_TYPE_PLAYBACK_DEVICE,
104                 CEC_DEVICE_TYPE_AUDIO_SYSTEM,
105                 CEC_DEVICE_TYPE_SWITCH
106             })
107     public @interface CecDeviceType {}
108 
109     public static final int CEC_DEVICE_TYPE_UNKNOWN = -1;
110     public static final int CEC_DEVICE_TYPE_TV = 0;
111     public static final int CEC_DEVICE_TYPE_RECORDER = 1;
112     public static final int CEC_DEVICE_TYPE_RESERVED = 2;
113     public static final int CEC_DEVICE_TYPE_TUNER = 3;
114     public static final int CEC_DEVICE_TYPE_PLAYBACK_DEVICE = 4;
115     public static final int CEC_DEVICE_TYPE_AUDIO_SYSTEM = 5;
116     public static final int CEC_DEVICE_TYPE_SWITCH = 6;
117     public static final int CEC_DEVICE_TYPE_VIDEO_PROCESSOR = 7;
118 
119     /** Feature Abort Reasons */
120     public static final int ABORT_UNRECOGNIZED_MODE = 0;
121     public static final int ABORT_NOT_IN_CORRECT_MODE = 1;
122     public static final int ABORT_CANNOT_PROVIDE_SOURCE = 2;
123     public static final int ABORT_INVALID_OPERAND = 3;
124     public static final int ABORT_REFUSED = 4;
125     public static final int ABORT_UNABLE_TO_DETERMINE = 5;
126 
127     // CEC versions
128     public static final int CEC_VERSION_1_4 = 0x05;
129     public static final int CEC_VERSION_2_0 = 0x06;
130 
131     /** CEC Power Status */
132     public static final int CEC_POWER_STATUS_ON = 0x0;
133     public static final int CEC_POWER_STATUS_STANDBY = 0x1;
134     public static final int CEC_POWER_STATUS_IN_TRANSITION_TO_ON = 0x2;
135     public static final int CEC_POWER_STATUS_IN_TRANSITION_TO_STANDBY = 0x3;
136 
137     /** PowerManager wakefulness states */
138     public static final String WAKEFULNESS_AWAKE = "Awake";
139     public static final String WAKEFULNESS_ASLEEP = "Asleep";
140 
141     /** Poll Message Success */
142     public static final String POLL_SUCCESS = "POLL message sent";
143 
144     // CEC Device feature list
145     public static final String HDMI_CEC_FEATURE = "feature:android.hardware.hdmi.cec";
146     public static final String LEANBACK_FEATURE = "feature:android.software.leanback";
147 
148     // Device property list used in CTS
149     public static final String HDMI_DEVICE_TYPE_PROPERTY = "ro.hdmi.device_type";
150     public static final String PROPERTY_ARC_SUPPORT = "persist.sys.hdmi.property_arc_support";
151     public static final String PROPERTY_BUILD_FINGERPRINT = "ro.system.build.fingerprint";
152 
153     /*
154      * The default name of local directory into which the port to device mapping files are stored.
155      */
156     public static final File CEC_MAP_FOLDER =
157             new File(System.getProperty("java.io.tmpdir"), "cec-cts-temp");
158 
159     // CEC Settings
160     public static final String SETTING_VOLUME_CONTROL_ENABLED = "volume_control_enabled";
161     public static final String SETTING_SOUNDBAR_MODE_ENABLED = "soundbar_mode";
162 
163     // CEC Settings Values
164     public static final String VOLUME_CONTROL_ENABLED = "1";
165     public static final String VOLUME_CONTROL_DISABLED = "0";
166     public static final String SOUNDBAR_MODE_ENABLED = "1";
167     public static final String SOUNDBAR_MODE_DISABLED = "0";
168     // Power Control Modes for source devices
169     public static final String POWER_CONTROL_MODE_BROADCAST = "broadcast";
170     public static final String POWER_CONTROL_MODE_NONE = "none";
171     public static final String POWER_CONTROL_MODE_TV = "to_tv";
172     public static final String POWER_CONTROL_MODE_TV_AND_AUDIO_SYSTEM = "to_tv_and_audio_system";
173 
174     // Power State Change on Active Source Lost Settings values
175     public static final String POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_NONE = "none";
176     public static final String POWER_STATE_CHANGE_ON_ACTIVE_SOURCE_LOST_STANDBY_NOW = "standby_now";
177 
178     // Short Audio Descriptors that can be queried
179     public static final String QUERY_SAD_LPCM = "query_sad_lpcm";
180     public static final String QUERY_SAD_DD = "query_sad_dd";
181     public static final String QUERY_SAD_MPEG1 = "query_sad_mpeg1";
182     public static final String QUERY_SAD_MP3 = "query_sad_mp3";
183     public static final String QUERY_SAD_MPEG2 = "query_sad_mpeg2";
184     public static final String QUERY_SAD_AAC = "query_sad_aac";
185     public static final String QUERY_SAD_DTS = "query_sad_dts";
186     public static final String QUERY_SAD_ATRAC = "query_sad_atrac";
187     public static final String QUERY_SAD_ONEBITAUDIO = "query_sad_onebitaudio";
188     public static final String QUERY_SAD_DDP = "query_sad_ddp";
189     public static final String QUERY_SAD_DTSHD = "query_sad_dtshd";
190     public static final String QUERY_SAD_TRUEHD = "query_sad_truehd";
191     public static final String QUERY_SAD_DST = "query_sad_dst";
192     public static final String QUERY_SAD_WMAPRO = "query_sad_wmapro";
193     public static final String QUERY_SAD_MAX = "query_sad_max";
194 
195     // Whether to query an SAD or not
196     public static final String QUERY_SAD_DISABLED = "0";
197     public static final String QUERY_SAD_ENABLED = "1";
198 
199     // Audio codecs
200     public static final int AUDIO_CODEC_NONE = 0x0;
201     public static final int AUDIO_CODEC_LPCM = 0x1; // Support LPCMs
202     public static final int AUDIO_CODEC_DD = 0x2; // Support DD
203     public static final int AUDIO_CODEC_MPEG1 = 0x3; // Support MPEG1
204     public static final int AUDIO_CODEC_MP3 = 0x4; // Support MP3
205     public static final int AUDIO_CODEC_MPEG2 = 0x5; // Support MPEG2
206     public static final int AUDIO_CODEC_AAC = 0x6; // Support AAC
207     public static final int AUDIO_CODEC_DTS = 0x7; // Support DTS
208     public static final int AUDIO_CODEC_ATRAC = 0x8; // Support ATRAC
209     public static final int AUDIO_CODEC_ONEBITAUDIO = 0x9; // Support One-Bit Audio
210     public static final int AUDIO_CODEC_DDP = 0xA; // Support DDP
211     public static final int AUDIO_CODEC_DTSHD = 0xB; // Support DTSHD
212     public static final int AUDIO_CODEC_TRUEHD = 0xC; // Support MLP/TRUE-HD
213     public static final int AUDIO_CODEC_DST = 0xD; // Support DST
214     public static final int AUDIO_CODEC_WMAPRO = 0xE; // Support WMA-Pro
215     public static final int AUDIO_CODEC_MAX = 0xF;
216 
217     // CEC 2.0 Report Feature Bits
218     public static final int FEATURES_SINK_SUPPORTS_ARC_TX_BIT = 0x4;
219     public static final int FEATURES_SINK_SUPPORTS_ARC_RX_BIT = 0x2;
220 
221     // Audio device types from AudioDeviceInfo
222     public static final int DEVICE_OUT_HDMI = 0x400;
223     public static final int DEVICE_OUT_HDMI_ARC = 0x40000;
224     public static final int DEVICE_OUT_HDMI_EARC = 0x40001;
225 
226     // Volume behavior constants from AudioManager
227     public static final int DEVICE_VOLUME_BEHAVIOR_VARIABLE = 0;
228     public static final int DEVICE_VOLUME_BEHAVIOR_FULL = 1;
229     public static final int DEVICE_VOLUME_BEHAVIOR_FIXED = 2;
230     public static final int DEVICE_VOLUME_BEHAVIOR_ABSOLUTE = 3;
231 }
232