Constants.java revision 7ecfbaed6e902aea151bc1919cf7771bbd868fc4
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
17package com.android.server.hdmi;
18
19/**
20 * Defines constants related to HDMI-CEC protocol internal implementation.
21 * If a constant will be used in the public api, it should be located in
22 * {@link android.hardware.hdmi.HdmiCec}.
23 */
24final class Constants {
25
26    /** Logical address for TV */
27    public static final int ADDR_TV = 0;
28
29    /** Logical address for recorder 1 */
30    public static final int ADDR_RECORDER_1 = 1;
31
32    /** Logical address for recorder 2 */
33    public static final int ADDR_RECORDER_2 = 2;
34
35    /** Logical address for tuner 1 */
36    public static final int ADDR_TUNER_1 = 3;
37
38    /** Logical address for playback 1 */
39    public static final int ADDR_PLAYBACK_1 = 4;
40
41    /** Logical address for audio system */
42    public static final int ADDR_AUDIO_SYSTEM = 5;
43
44    /** Logical address for tuner 2 */
45    public static final int ADDR_TUNER_2 = 6;
46
47    /** Logical address for tuner 3 */
48    public static final int ADDR_TUNER_3 = 7;
49
50    /** Logical address for playback 2 */
51    public static final int ADDR_PLAYBACK_2 = 8;
52
53    /** Logical address for recorder 3 */
54    public static final int ADDR_RECORDER_3 = 9;
55
56    /** Logical address for tuner 4 */
57    public static final int ADDR_TUNER_4 = 10;
58
59    /** Logical address for playback 3 */
60    public static final int ADDR_PLAYBACK_3 = 11;
61
62    /** Logical address reserved for future usage */
63    public static final int ADDR_RESERVED_1 = 12;
64
65    /** Logical address reserved for future usage */
66    public static final int ADDR_RESERVED_2 = 13;
67
68    /** Logical address for TV other than the one assigned with {@link #ADDR_TV} */
69    public static final int ADDR_SPECIFIC_USE = 14;
70
71    /** Logical address for devices to which address cannot be allocated */
72    public static final int ADDR_UNREGISTERED = 15;
73
74    /** Logical address used in the destination address field for broadcast messages */
75    public static final int ADDR_BROADCAST = 15;
76
77    /** Logical address used to indicate it is not initialized or invalid. */
78    public static final int ADDR_INVALID = -1;
79
80    /** Logical address used to indicate the source comes from internal device. */
81    public static final int ADDR_INTERNAL = 0xFFFF;
82
83    static final int MESSAGE_FEATURE_ABORT = 0x00;
84    static final int MESSAGE_IMAGE_VIEW_ON = 0x04;
85    static final int MESSAGE_TUNER_STEP_INCREMENT = 0x05;
86    static final int MESSAGE_TUNER_STEP_DECREMENT = 0x06;
87    static final int MESSAGE_TUNER_DEVICE_STATUS = 0x07;
88    static final int MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08;
89    static final int MESSAGE_RECORD_ON = 0x09;
90    static final int MESSAGE_RECORD_STATUS = 0x0A;
91    static final int MESSAGE_RECORD_OFF = 0x0B;
92    static final int MESSAGE_TEXT_VIEW_ON = 0x0D;
93    static final int MESSAGE_RECORD_TV_SCREEN = 0x0F;
94    static final int MESSAGE_GIVE_DECK_STATUS = 0x1A;
95    static final int MESSAGE_DECK_STATUS = 0x1B;
96    static final int MESSAGE_SET_MENU_LANGUAGE = 0x32;
97    static final int MESSAGE_CLEAR_ANALOG_TIMER = 0x33;
98    static final int MESSAGE_SET_ANALOG_TIMER = 0x34;
99    static final int MESSAGE_TIMER_STATUS = 0x35;
100    static final int MESSAGE_STANDBY = 0x36;
101    static final int MESSAGE_PLAY = 0x41;
102    static final int MESSAGE_DECK_CONTROL = 0x42;
103    static final int MESSAGE_TIMER_CLEARED_STATUS = 0x043;
104    static final int MESSAGE_USER_CONTROL_PRESSED = 0x44;
105    static final int MESSAGE_USER_CONTROL_RELEASED = 0x45;
106    static final int MESSAGE_GIVE_OSD_NAME = 0x46;
107    static final int MESSAGE_SET_OSD_NAME = 0x47;
108    static final int MESSAGE_SET_OSD_STRING = 0x64;
109    static final int MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67;
110    static final int MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70;
111    static final int MESSAGE_GIVE_AUDIO_STATUS = 0x71;
112    static final int MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72;
113    static final int MESSAGE_REPORT_AUDIO_STATUS = 0x7A;
114    static final int MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D;
115    static final int MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E;
116    static final int MESSAGE_ROUTING_CHANGE = 0x80;
117    static final int MESSAGE_ROUTING_INFORMATION = 0x81;
118    static final int MESSAGE_ACTIVE_SOURCE = 0x82;
119    static final int MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83;
120    static final int MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84;
121    static final int MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85;
122    static final int MESSAGE_SET_STREAM_PATH = 0x86;
123    static final int MESSAGE_DEVICE_VENDOR_ID = 0x87;
124    static final int MESSAGE_VENDOR_COMMAND = 0x89;
125    static final int MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A;
126    static final int MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B;
127    static final int MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C;
128    static final int MESSAGE_MENU_REQUEST = 0x8D;
129    static final int MESSAGE_MENU_STATUS = 0x8E;
130    static final int MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F;
131    static final int MESSAGE_REPORT_POWER_STATUS = 0x90;
132    static final int MESSAGE_GET_MENU_LANGUAGE = 0x91;
133    static final int MESSAGE_SELECT_ANALOG_SERVICE = 0x92;
134    static final int MESSAGE_SELECT_DIGITAL_SERVICE = 0x93;
135    static final int MESSAGE_SET_DIGITAL_TIMER = 0x97;
136    static final int MESSAGE_CLEAR_DIGITAL_TIMER = 0x99;
137    static final int MESSAGE_SET_AUDIO_RATE = 0x9A;
138    static final int MESSAGE_INACTIVE_SOURCE = 0x9D;
139    static final int MESSAGE_CEC_VERSION = 0x9E;
140    static final int MESSAGE_GET_CEC_VERSION = 0x9F;
141    static final int MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0;
142    static final int MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1;
143    static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2;
144    static final int MESSAGE_REPORT_SHORT_AUDIO_DESCRIPTOR = 0xA3;
145    static final int MESSAGE_REQUEST_SHORT_AUDIO_DESCRIPTOR = 0xA4;
146    static final int MESSAGE_INITIATE_ARC = 0xC0;
147    static final int MESSAGE_REPORT_ARC_INITIATED = 0xC1;
148    static final int MESSAGE_REPORT_ARC_TERMINATED = 0xC2;
149    static final int MESSAGE_REQUEST_ARC_INITIATION = 0xC3;
150    static final int MESSAGE_REQUEST_ARC_TERMINATION = 0xC4;
151    static final int MESSAGE_TERMINATE_ARC = 0xC5;
152    static final int MESSAGE_CDC_MESSAGE = 0xF8;
153    static final int MESSAGE_ABORT = 0xFF;
154
155    static final int UNKNOWN_VENDOR_ID = 0xFFFFFF;
156
157    static final int TRUE = 1;
158    static final int FALSE = 0;
159
160    // Constants related to operands of HDMI CEC commands.
161    // Refer to CEC Table 29 in HDMI Spec v1.4b.
162    // [Abort Reason]
163    static final int ABORT_UNRECOGNIZED_MODE = 0;
164    static final int ABORT_NOT_IN_CORRECT_MODE = 1;
165    static final int ABORT_CANNOT_PROVIDE_SOURCE = 2;
166    static final int ABORT_INVALID_OPERAND = 3;
167    static final int ABORT_REFUSED = 4;
168    static final int ABORT_UNABLE_TO_DETERMINE = 5;
169
170    // [Audio Status]
171    static final int SYSTEM_AUDIO_STATUS_OFF = 0;
172    static final int SYSTEM_AUDIO_STATUS_ON = 1;
173
174    // Bit mask used to get the routing path of the top level device.
175    // When &'d with the path 1.2.2.0 (0x1220), for instance, gives 1.0.0.0.
176    static final int ROUTING_PATH_TOP_MASK = 0xF000;
177    static final int ROUTING_PATH_TOP_SHIFT = 12;
178
179    static final int INVALID_PORT_ID = -1;
180    static final int INVALID_PHYSICAL_ADDRESS = 0xFFFF;
181
182    // Send result codes.
183    static final int SEND_RESULT_SUCCESS = 0;
184    static final int SEND_RESULT_NAK = -1;
185    static final int SEND_RESULT_FAILURE = -2;
186
187    // Strategy for device polling.
188    // Should use "OR(|) operation of POLL_STRATEGY_XXX and POLL_ITERATION_XXX.
189    static final int POLL_STRATEGY_MASK = 0x3;  // first and second bit.
190    static final int POLL_STRATEGY_REMOTES_DEVICES = 0x1;
191    static final int POLL_STRATEGY_SYSTEM_AUDIO = 0x2;
192
193    static final int POLL_ITERATION_STRATEGY_MASK = 0x30000;  // first and second bit.
194    static final int POLL_ITERATION_IN_ORDER = 0x10000;
195    static final int POLL_ITERATION_REVERSE_ORDER = 0x20000;
196
197    static final int UNKNOWN_VOLUME = -1;
198
199    // IRT(Initiator Repetition Time) in millisecond as recommended in the standard.
200    // Outgoing UCP commands, when in 'Press and Hold' mode, should be this much apart
201    // from the adjacent one so as not to place unnecessarily heavy load on the CEC line.
202    // TODO: This value might need tweaking per product basis. Consider putting it
203    //       in config.xml to allow customization.
204    static final int IRT_MS = 300;
205
206    private Constants() { /* cannot be instantiated */ }
207}
208