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     POLL(-1),
24     FEATURE_ABORT(0x00),
25     IMAGE_VIEW_ON(0x04),
26     GIVE_TUNER_DEVICE_STATUS(0x08),
27     RECORD_ON(0x09),
28     RECORD_OFF(0x0b),
29     TEXT_VIEW_ON(0x0d),
30     RECORD_TV_SCREEN(0x0f),
31     GIVE_DECK_STATUS(0x1a),
32     SET_MENU_LANGUAGE(0x32),
33     CLEAR_ANALOG_TIMER(0x33),
34     SET_ANALOG_TIMER(0x34),
35     STANDBY(0x36),
36     PLAY(0x41),
37     DECK_CONTROL(0x42),
38     USER_CONTROL_PRESSED(0x44),
39     USER_CONTROL_RELEASED(0x45),
40     GIVE_OSD_NAME(0x46),
41     SET_OSD_NAME(0x47),
42     SYSTEM_AUDIO_MODE_REQUEST(0x70),
43     GIVE_AUDIO_STATUS(0x71),
44     SET_SYSTEM_AUDIO_MODE(0x72),
45     SET_AUDIO_VOLUME_LEVEL(0x73),
46     REPORT_AUDIO_STATUS(0x7a),
47     GIVE_SYSTEM_AUDIO_MODE_STATUS(0x7d),
48     SYSTEM_AUDIO_MODE_STATUS(0x7e),
49     ROUTING_CHANGE(0x80),
50     ACTIVE_SOURCE(0x82),
51     GIVE_PHYSICAL_ADDRESS(0x83),
52     REPORT_PHYSICAL_ADDRESS(0x84),
53     REQUEST_ACTIVE_SOURCE(0x85),
54     SET_STREAM_PATH(0x86),
55     DEVICE_VENDOR_ID(0x87),
56     VENDOR_COMMAND(0x89),
57     GIVE_DEVICE_VENDOR_ID(0x8c),
58     MENU_REQUEST(0x8d),
59     MENU_STATUS(0x8e),
60     GIVE_POWER_STATUS(0x8f),
61     REPORT_POWER_STATUS(0x90),
62     GET_MENU_LANGUAGE(0x91),
63     SET_DIGITAL_TIMER(0x97),
64     CLEAR_DIGITAL_TIMER(0x99),
65     INACTIVE_SOURCE(0x9d),
66     CEC_VERSION(0x9e),
67     GET_CEC_VERSION(0x9f),
68     VENDOR_COMMAND_WITH_ID(0Xa0),
69     CLEAR_EXTERNAL_TIMER(0xa1),
70     REPORT_SHORT_AUDIO_DESCRIPTOR(0xa3),
71     REQUEST_SHORT_AUDIO_DESCRIPTOR(0xa4),
72     GIVE_FEATURES(0xa5),
73     REPORT_FEATURES(0xa6),
74     INITIATE_ARC(0xc0),
75     ARC_INITIATED(0xc1),
76     ARC_TERMINATED(0xc2),
77     REQUEST_ARC_INITIATION(0xc3),
78     REQUEST_ARC_TERMINATION(0xc4),
79     TERMINATE_ARC(0xc5),
80     ABORT(0xff);
81 
82     private final int operandCode;
83     private static Map operandMap = new HashMap<>();
84 
85     static {
86         for (CecOperand operand : CecOperand.values()) {
operandMap.put(operand.operandCode, operand)87             operandMap.put(operand.operandCode, operand);
88         }
89     }
90 
getOperand(int messageId)91     public static CecOperand getOperand(int messageId) {
92         return (CecOperand) operandMap.get(messageId);
93     }
94 
95     @Override
toString()96     public String toString() {
97         return String.format("%02x", operandCode);
98     }
99 
CecOperand(int operandCode)100     private CecOperand(int operandCode) {
101         this.operandCode = operandCode;
102     }
103 }
104