1 /*
2  * Copyright (C) 2020 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 java.util.HashMap;
20 import java.util.Map;
21 
22 public enum CecOperand {
23     FEATURE_ABORT(0x00),
24     TEXT_VIEW_ON(0x0d),
25     SET_MENU_LANGUAGE(0x32),
26     STANDBY(0x36),
27     USER_CONTROL_PRESSED(0x44),
28     USER_CONTROL_RELEASED(0x45),
29     GIVE_OSD_NAME(0x46),
30     SET_OSD_NAME(0x47),
31     SYSTEM_AUDIO_MODE_REQUEST(0x70),
32     GIVE_AUDIO_STATUS(0x71),
33     SET_SYSTEM_AUDIO_MODE(0x72),
34     REPORT_AUDIO_STATUS(0x7a),
35     GIVE_SYSTEM_AUDIO_MODE_STATUS(0x7d),
36     SYSTEM_AUDIO_MODE_STATUS(0x7e),
37     ACTIVE_SOURCE(0x82),
38     GIVE_PHYSICAL_ADDRESS(0x83),
39     REPORT_PHYSICAL_ADDRESS(0x84),
40     REQUEST_ACTIVE_SOURCE(0x85),
41     SET_STREAM_PATH(0x86),
42     DEVICE_VENDOR_ID(0x87),
43     VENDOR_COMMAND(0x89),
44     GIVE_DEVICE_VENDOR_ID(0x8c),
45     GIVE_POWER_STATUS(0x8f),
46     REPORT_POWER_STATUS(0x90),
47     GET_MENU_LANGUAGE(0x91),
48     INACTIVE_SOURCE(0x9d),
49     CEC_VERSION(0x9e),
50     GET_CEC_VERSION(0x9f),
51     REPORT_SHORT_AUDIO_DESCRIPTOR(0xa3),
52     REQUEST_SHORT_AUDIO_DESCRIPTOR(0xa4),
53     INITIATE_ARC(0xc0),
54     ARC_INITIATED(0xc1),
55     REQUEST_ARC_INITIATION(0xc3),
56     REQUEST_ARC_TERMINATION(0xc4),
57     TERMINATE_ARC(0xc5),
58     ABORT(0xff);
59 
60     private final int operandCode;
61     private static Map operandMap = new HashMap<>();
62 
63     static {
64         for (CecOperand operand : CecOperand.values()) {
operandMap.put(operand.operandCode, operand)65             operandMap.put(operand.operandCode, operand);
66         }
67     }
68 
getOperand(int messageId)69     public static CecOperand getOperand(int messageId) {
70         return (CecOperand) operandMap.get(messageId);
71     }
72 
73     @Override
toString()74     public String toString() {
75         return String.format("%02x", operandCode);
76     }
77 
CecOperand(int operandCode)78     private CecOperand(int operandCode) {
79         this.operandCode = operandCode;
80     }
81 }
82