tizen 2.3 release
[framework/system/deviced.git] / src / hdmi-cec / libcec.h
1 /*
2  * Copyright@ Samsung Electronics Co. LTD
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 #ifndef _LIBCEC_H_
18 #define _LIBCEC_H_
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 /* Maximum CEC frame size */
25 #define CEC_MAX_FRAME_SIZE                16
26 /* Not valid CEC physical address */
27 #define CEC_NOT_VALID_PHYSICAL_ADDRESS    0xFFFF
28
29 /* CEC broadcast address (as destination address) */
30 #define CEC_MSG_BROADCAST        0x0F
31 /* CEC unregistered address (as initiator address) */
32 #define CEC_LADDR_UNREGISTERED   0x0F
33
34 /*
35  * CEC Messages
36  */
37
38 /* @name Messages for the One Touch Play Feature */
39 #define CEC_OPCODE_ACTIVE_SOURCE            0x82
40 #define CEC_OPCODE_IMAGE_VIEW_ON            0x04
41 #define CEC_OPCODE_TEXT_VIEW_ON             0x0D
42
43 /* @name Messages for the Routing Control Feature */
44 #define CEC_OPCODE_INACTIVE_SOURCE          0x9D
45 #define CEC_OPCODE_REQUEST_ACTIVE_SOURCE    0x85
46 #define CEC_OPCODE_ROUTING_CHANGE           0x80
47 #define CEC_OPCODE_ROUTING_INFORMATION      0x81
48 #define CEC_OPCODE_SET_STREAM_PATH          0x86
49
50 /* @name Messages for the Standby Feature */
51 #define CEC_OPCODE_STANDBY                  0x36
52
53 /* @name Messages for the One Touch Record Feature */
54 #define CEC_OPCODE_RECORD_OFF               0x0B
55 #define CEC_OPCODE_RECORD_ON                0x09
56 #define CEC_OPCODE_RECORD_STATUS            0x0A
57 #define CEC_OPCODE_RECORD_TV_SCREEN         0x0F
58
59 /* @name Messages for the Timer Programming Feature */
60 #define CEC_OPCODE_CLEAR_ANALOGUE_TIMER     0x33
61 #define CEC_OPCODE_CLEAR_DIGITAL_TIMER      0x99
62 #define CEC_OPCODE_CLEAR_EXTERNAL_TIMER     0xA1
63 #define CEC_OPCODE_SET_ANALOGUE_TIMER       0x34
64 #define CEC_OPCODE_SET_DIGITAL_TIMER        0x97
65 #define CEC_OPCODE_SET_EXTERNAL_TIMER       0xA2
66 #define CEC_OPCODE_SET_TIMER_PROGRAM_TITLE  0x67
67 #define CEC_OPCODE_TIMER_CLEARED_STATUS     0x43
68 #define CEC_OPCODE_TIMER_STATUS             0x35
69
70 /* @name Messages for the System Information Feature */
71 #define CEC_OPCODE_CEC_VERSION              0x9E
72 #define CEC_OPCODE_GET_CEC_VERSION          0x9F
73 #define CEC_OPCODE_GIVE_PHYSICAL_ADDRESS    0x83
74 #define CEC_OPCODE_GET_MENU_LANGUAGE        0x91
75 //#define CEC_OPCODE_POLLING_MESSAGE
76 #define CEC_OPCODE_REPORT_PHYSICAL_ADDRESS  0x84
77 #define CEC_OPCODE_SET_MENU_LANGUAGE        0x32
78
79 /* @name Messages for the Deck Control Feature */
80 #define CEC_OPCODE_DECK_CONTROL             0x42
81 #define CEC_OPCODE_DECK_STATUS              0x1B
82 #define CEC_OPCODE_GIVE_DECK_STATUS         0x1A
83 #define CEC_OPCODE_PLAY                     0x41
84
85 /* @name Messages for the Tuner Control Feature */
86 #define CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS 0x08
87 #define CEC_OPCODE_SELECT_ANALOGUE_SERVICE  0x92
88 #define CEC_OPCODE_SELECT_DIGITAL_SERVICE   0x93
89 #define CEC_OPCODE_TUNER_DEVICE_STATUS      0x07
90 #define CEC_OPCODE_TUNER_STEP_DECREMENT     0x06
91 #define CEC_OPCODE_TUNER_STEP_INCREMENT     0x05
92
93 /* @name Messages for the Vendor Specific Commands Feature */
94 #define CEC_OPCODE_DEVICE_VENDOR_ID         0x87
95 #define CEC_OPCODE_GET_DEVICE_VENDOR_ID     0x8C
96 #define CEC_OPCODE_VENDOR_COMMAND           0x89
97 #define CEC_OPCODE_VENDOR_COMMAND_WITH_ID   0xA0
98 #define CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN 0x8A
99 #define CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP  0x8B
100
101 /* @name Messages for the OSD Display Feature */
102 #define CEC_OPCODE_SET_OSD_STRING           0x64
103
104 /* @name Messages for the Device OSD Transfer Feature */
105 #define CEC_OPCODE_GIVE_OSD_NAME            0x46
106 #define CEC_OPCODE_SET_OSD_NAME             0x47
107
108 /* @name Messages for the Device Menu Control Feature */
109 #define CEC_OPCODE_MENU_REQUEST             0x8D
110 #define CEC_OPCODE_MENU_STATUS              0x8E
111 #define CEC_OPCODE_USER_CONTROL_PRESSED     0x44
112 #define CEC_OPCODE_USER_CONTROL_RELEASED    0x45
113
114 /* @name Messages for the Remote Control Passthrough Feature */
115
116 /* @name Messages for the Power Status Feature */
117 #define CEC_OPCODE_GIVE_DEVICE_POWER_STATUS 0x8F
118 #define CEC_OPCODE_REPORT_POWER_STATUS      0x90
119
120 /* @name Messages for General Protocol messages */
121 #define CEC_OPCODE_FEATURE_ABORT            0x00
122 #define CEC_OPCODE_ABORT                    0xFF
123
124 /* @name Messages for the System Audio Control Feature */
125 #define CEC_OPCODE_GIVE_AUDIO_STATUS        0x71
126 #define CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS 0x7D
127 #define CEC_OPCODE_REPORT_AUDIO_STATUS      0x7A
128 #define CEC_OPCODE_SET_SYSTEM_AUDIO_MODE    0x72
129 #define CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST 0x70
130 #define CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS 0x7E
131
132 /* @name Messages for the Audio Rate Control Feature */
133 #define CEC_OPCODE_SET_AUDIO_RATE           0x9A
134
135 /* @name CEC Operands */
136
137 /* TODO: not finished */
138
139 #define CEC_DECK_CONTROL_MODE_STOP      0x03
140 #define CEC_PLAY_MODE_PLAY_FORWARD      0x24
141
142 /*
143  * @enum CECDeviceType
144  * Type of CEC device
145  */
146 enum CECDeviceType {
147     /* TV */
148     CEC_DEVICE_TV,
149     /* Recording Device */
150     CEC_DEVICE_RECODER,
151     /* Reserved */
152     CEC_RESERVED,
153     /* Tuner */
154     CEC_DEVICE_TUNER,
155     /* Playback Device */
156     CEC_DEVICE_PLAYER,
157     /* Audio System */
158     CEC_DEVICE_AUDIO,
159 };
160
161 int CECOpen();
162 int CECClose();
163 int CECAllocLogicalAddress(int paddr, enum CECDeviceType devtype);
164 int CECSendMessage(unsigned char *buffer, int size);
165 int CECReceiveMessage(unsigned char *buffer, int size, long timeout);
166
167 int CECIgnoreMessage(unsigned char opcode, unsigned char lsrc);
168 int CECCheckMessageSize(unsigned char opcode, int size);
169 int CECCheckMessageMode(unsigned char opcode, int broadcast);
170 int CECProcessOpcode(unsigned char *buffer, int laddr, int paddr, int raddr);
171 int CECReportKey(unsigned int key);
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #endif /* _LIBCEC_H_ */