cec: added vendor code for pioneer
[deb_libcec.git] / src / lib / LibCECC.cpp
CommitLineData
abbca718
LOK
1/*
2 * This file is part of the libCEC(R) library.
3 *
4 * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
761dcc45
LOK
33#include <cec.h>
34#include <cecc.h>
abbca718
LOK
35
36using namespace CEC;
37using namespace std;
38
39/*!
40 * C interface implementation
41 */
42//@{
2abe74eb 43ICECAdapter *cec_parser;
abbca718 44
02ee2c68 45int cec_init(const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint8_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
abbca718 46{
2abe74eb 47 cec_parser = (ICECAdapter *) CECCreate(strDeviceName, iLogicalAddress, iPhysicalAddress);
02ee2c68 48 return (cec_parser != NULL) ? 1 : 0;
abbca718
LOK
49}
50
5f39c4d8
LOK
51void cec_destroy(void)
52{
53 cec_close();
25701fa6 54 CECDestroy(cec_parser);
5f39c4d8
LOK
55 cec_parser = NULL;
56}
57
02ee2c68 58int cec_open(const char *strPort, uint32_t iTimeout)
abbca718
LOK
59{
60 if (cec_parser)
61 return cec_parser->Open(strPort, iTimeout);
62 return false;
63}
64
5f39c4d8 65void cec_close(void)
f99bc831 66{
f99bc831 67 if (cec_parser)
5f39c4d8 68 cec_parser->Close();
f99bc831
LOK
69}
70
25701fa6 71int8_t cec_find_adapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */)
abbca718
LOK
72{
73 if (cec_parser)
25701fa6 74 return cec_parser->FindAdapters(deviceList, iBufSize, strDevicePath);
2abe74eb 75 return -1;
abbca718
LOK
76}
77
02ee2c68 78int cec_ping_adapters(void)
abbca718
LOK
79{
80 if (cec_parser)
02ee2c68
LOK
81 return cec_parser->PingAdapter() ? 1 : 0;
82 return -1;
abbca718
LOK
83}
84
02ee2c68 85int cec_start_bootloader(void)
abbca718
LOK
86{
87 if (cec_parser)
02ee2c68
LOK
88 return cec_parser->StartBootloader() ? 1 : 0;
89 return -1;
abbca718
LOK
90}
91
25701fa6 92int8_t cec_get_min_version(void)
abbca718
LOK
93{
94 if (cec_parser)
d75be19b 95 return cec_parser->GetMinLibVersion();
2abe74eb 96 return -1;
abbca718
LOK
97}
98
d75be19b 99int8_t cec_get_lib_version_major(void)
abbca718
LOK
100{
101 if (cec_parser)
d75be19b 102 return cec_parser->GetLibVersionMajor();
2abe74eb 103 return -1;
abbca718
LOK
104}
105
eafd9bed
LOK
106int8_t cec_get_lib_version_minor(void)
107{
108 if (cec_parser)
109 return cec_parser->GetLibVersionMinor();
110 return -1;
111}
112
02ee2c68 113int cec_get_next_log_message(cec_log_message *message)
abbca718
LOK
114{
115 if (cec_parser)
02ee2c68
LOK
116 return cec_parser->GetNextLogMessage(message) ? 1 : 0;
117 return -1;
abbca718
LOK
118}
119
02ee2c68 120int cec_get_next_keypress(cec_keypress *key)
abbca718
LOK
121{
122 if (cec_parser)
02ee2c68
LOK
123 return cec_parser->GetNextKeypress(key) ? 1 : 0;
124 return -1;
abbca718
LOK
125}
126
02ee2c68 127int cec_get_next_command(cec_command *command)
825ddb96
LOK
128{
129 if (cec_parser)
02ee2c68
LOK
130 return cec_parser->GetNextCommand(command) ? 1 : 0;
131 return -1;
825ddb96
LOK
132}
133
8d84e2c0 134int cec_transmit(const CEC::cec_command &data)
abbca718
LOK
135{
136 if (cec_parser)
8d84e2c0 137 return cec_parser->Transmit(data) ? 1 : 0;
02ee2c68 138 return -1;
abbca718
LOK
139}
140
2492216a 141int cec_set_logical_address(cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */)
abbca718
LOK
142{
143 if (cec_parser)
02ee2c68
LOK
144 return cec_parser->SetLogicalAddress(iLogicalAddress) ? 1 : 0;
145 return -1;
6dfe9213
LOK
146}
147
2492216a
LOK
148int cec_set_physical_address(uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
149{
150 if (cec_parser)
151 return cec_parser->SetPhysicalAddress(iPhysicalAddress) ? 1 : 0;
152 return -1;
153}
154
02ee2c68 155int cec_power_on_devices(cec_logical_address address /* = CECDEVICE_TV */)
6dfe9213
LOK
156{
157 if (cec_parser)
02ee2c68
LOK
158 return cec_parser->PowerOnDevices(address) ? 1 : 0;
159 return -1;
abbca718
LOK
160}
161
02ee2c68 162int cec_standby_devices(cec_logical_address address /* = CECDEVICE_BROADCAST */)
abbca718
LOK
163{
164 if (cec_parser)
02ee2c68
LOK
165 return cec_parser->StandbyDevices(address) ? 1 : 0;
166 return -1;
abbca718
LOK
167}
168
02ee2c68 169int cec_set_active_view(void)
abbca718
LOK
170{
171 if (cec_parser)
02ee2c68
LOK
172 return cec_parser->SetActiveView() ? 1 : 0;
173 return -1;
abbca718
LOK
174}
175
02ee2c68 176int cec_set_inactive_view(void)
abbca718
LOK
177{
178 if (cec_parser)
02ee2c68
LOK
179 return cec_parser->SetInactiveView() ? 1 : 0;
180 return -1;
abbca718
LOK
181}
182
1969b140
LOK
183int cec_set_osd_string(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage)
184{
185 if (cec_parser)
186 return cec_parser->SetOSDString(iLogicalAddress, duration, strMessage) ? 1 : 0;
187 return -1;
188}
189
8b7e5ff6
LOK
190int cec_switch_monitoring(int bEnable)
191{
192 if (cec_parser)
193 return cec_parser->SwitchMonitoring(bEnable == 1) ? 1 : 0;
194 return -1;
195}
196
6a1c0009
LOK
197cec_version cec_get_device_cec_version(cec_logical_address iLogicalAddress)
198{
199 if (cec_parser)
200 return cec_parser->GetDeviceCecVersion(iLogicalAddress);
201 return CEC_VERSION_UNKNOWN;
202}
203
a3269a0a
LOK
204int cec_get_device_menu_language(cec_logical_address iLogicalAddress, cec_menu_language *language)
205{
206 if (cec_parser)
207 return cec_parser->GetDeviceMenuLanguage(iLogicalAddress, language) ? 1 : 0;
208 return -1;
209}
210
44c74256
LOK
211uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress)
212{
213 if (cec_parser)
214 return cec_parser->GetDeviceVendorId(iLogicalAddress);
215 return 0;
216}
217
e55f3f70
LOK
218cec_power_status cec_get_device_power_status(cec_logical_address iLogicalAddress)
219{
220 if (cec_parser)
221 return cec_parser->GetDevicePowerStatus(iLogicalAddress);
222 return CEC_POWER_STATUS_UNKNOWN;
223}
224
abbca718 225//@}