2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
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.
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.
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.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
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/
33 #include "../../include/cec.h"
34 #include "../../include/cecc.h"
40 * C interface implementation
43 ICECAdapter
*cec_parser
;
45 int cec_initialise(const libcec_configuration
*configuration
)
47 cec_parser
= (ICECAdapter
*) CECInitialise(configuration
);
48 return (cec_parser
!= NULL
) ? 1 : 0;
51 int cec_init_typed(const char *strDeviceName
, cec_device_type_list deviceTypes
)
53 cec_parser
= (ICECAdapter
*) CECInit(strDeviceName
, deviceTypes
);
54 return (cec_parser
!= NULL
) ? 1 : 0;
57 void cec_destroy(void)
60 CECDestroy(cec_parser
);
64 int cec_open(const char *strPort
, uint32_t iTimeout
)
67 return cec_parser
->Open(strPort
, iTimeout
);
77 int cec_enable_callbacks(void *cbParam
, ICECCallbacks
*callbacks
)
80 return cec_parser
->EnableCallbacks(cbParam
, callbacks
) ? 1 : 0;
84 int8_t cec_find_adapters(cec_adapter
*deviceList
, uint8_t iBufSize
, const char *strDevicePath
/* = NULL */)
87 return cec_parser
->FindAdapters(deviceList
, iBufSize
, strDevicePath
);
91 int cec_ping_adapters(void)
94 return cec_parser
->PingAdapter() ? 1 : 0;
98 int cec_start_bootloader(void)
101 return cec_parser
->StartBootloader() ? 1 : 0;
105 int8_t cec_get_min_lib_version(void)
108 return cec_parser
->GetMinLibVersion();
112 int8_t cec_get_lib_version_major(void)
115 return cec_parser
->GetLibVersionMajor();
119 int8_t cec_get_lib_version_minor(void)
122 return cec_parser
->GetLibVersionMinor();
126 int cec_get_next_log_message(cec_log_message
*message
)
129 return cec_parser
->GetNextLogMessage(message
) ? 1 : 0;
133 int cec_get_next_keypress(cec_keypress
*key
)
136 return cec_parser
->GetNextKeypress(key
) ? 1 : 0;
140 int cec_get_next_command(cec_command
*command
)
143 return cec_parser
->GetNextCommand(command
) ? 1 : 0;
147 int cec_transmit(const CEC::cec_command
*data
)
150 return cec_parser
->Transmit(*data
) ? 1 : 0;
154 int cec_set_logical_address(cec_logical_address iLogicalAddress
/* = CECDEVICE_PLAYBACKDEVICE1 */)
157 return cec_parser
->SetLogicalAddress(iLogicalAddress
) ? 1 : 0;
161 int cec_set_physical_address(uint16_t iPhysicalAddress
/* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
164 return cec_parser
->SetPhysicalAddress(iPhysicalAddress
) ? 1 : 0;
168 int cec_power_on_devices(cec_logical_address address
/* = CECDEVICE_TV */)
171 return cec_parser
->PowerOnDevices(address
) ? 1 : 0;
175 int cec_standby_devices(cec_logical_address address
/* = CECDEVICE_BROADCAST */)
178 return cec_parser
->StandbyDevices(address
) ? 1 : 0;
182 int cec_set_active_view(void)
185 return cec_parser
->SetActiveView() ? 1 : 0;
189 int cec_set_active_source(cec_device_type type
)
192 return cec_parser
->SetActiveSource(type
) ? 1 : 0;
196 int cec_set_deck_control_mode(cec_deck_control_mode mode
, int bSendUpdate
) {
198 return cec_parser
->SetDeckControlMode(mode
, bSendUpdate
== 1) ? 1 : 0;
202 int cec_set_deck_info(cec_deck_info info
, int bSendUpdate
) {
204 return cec_parser
->SetDeckInfo(info
, bSendUpdate
== 1) ? 1 : 0;
209 int cec_set_inactive_view(void)
212 return cec_parser
->SetInactiveView() ? 1 : 0;
216 int cec_set_menu_state(cec_menu_state state
, int bSendUpdate
) {
218 return cec_parser
->SetMenuState(state
, bSendUpdate
== 1) ? 1 : 0;
222 int cec_set_osd_string(cec_logical_address iLogicalAddress
, cec_display_control duration
, const char *strMessage
)
225 return cec_parser
->SetOSDString(iLogicalAddress
, duration
, strMessage
) ? 1 : 0;
229 int cec_switch_monitoring(int bEnable
)
232 return cec_parser
->SwitchMonitoring(bEnable
== 1) ? 1 : 0;
236 cec_version
cec_get_device_cec_version(cec_logical_address iLogicalAddress
)
239 return cec_parser
->GetDeviceCecVersion(iLogicalAddress
);
240 return CEC_VERSION_UNKNOWN
;
243 int cec_get_device_menu_language(cec_logical_address iLogicalAddress
, cec_menu_language
*language
)
246 return cec_parser
->GetDeviceMenuLanguage(iLogicalAddress
, language
) ? 1 : 0;
250 uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress
)
253 return cec_parser
->GetDeviceVendorId(iLogicalAddress
);
257 uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress
)
260 return cec_parser
->GetDevicePhysicalAddress(iLogicalAddress
);
264 cec_logical_address
cec_get_active_source(void)
267 return cec_parser
->GetActiveSource();
268 return CECDEVICE_UNKNOWN
;
271 int cec_is_active_source(cec_logical_address iAddress
)
274 return cec_parser
->IsActiveSource(iAddress
);
278 cec_power_status
cec_get_device_power_status(cec_logical_address iLogicalAddress
)
281 return cec_parser
->GetDevicePowerStatus(iLogicalAddress
);
282 return CEC_POWER_STATUS_UNKNOWN
;
285 int cec_poll_device(cec_logical_address iLogicalAddress
)
288 return cec_parser
->PollDevice(iLogicalAddress
) ? 1 : 0;
292 cec_logical_addresses
cec_get_active_devices(void)
294 cec_logical_addresses addresses
;
297 addresses
= cec_parser
->GetActiveDevices();
301 int cec_is_active_device(cec_logical_address iAddress
)
304 return cec_parser
->IsActiveDevice(iAddress
) ? 1 : 0;
308 int cec_is_active_device_type(cec_device_type type
)
311 return cec_parser
->IsActiveDeviceType(type
) ? 1 : 0;
315 int cec_set_hdmi_port(cec_logical_address iBaseDevice
, uint8_t iPort
)
318 return cec_parser
->SetHDMIPort(iBaseDevice
, iPort
) ? 1 : 0;
322 int cec_volume_up(int bSendRelease
)
325 return cec_parser
->VolumeUp(bSendRelease
== 1);
329 int cec_volume_down(int bSendRelease
)
332 return cec_parser
->VolumeDown(bSendRelease
== 1);
336 int cec_mute_audio(int bSendRelease
)
339 return cec_parser
->MuteAudio(bSendRelease
== 1);
343 int cec_send_keypress(cec_logical_address iDestination
, cec_user_control_code key
, int bWait
)
346 return cec_parser
->SendKeypress(iDestination
, key
, bWait
== 1) ? 1 : 0;
350 int cec_send_key_release(cec_logical_address iDestination
, int bWait
)
353 return cec_parser
->SendKeyRelease(iDestination
, bWait
== 1) ? 1 : 0;
357 cec_osd_name
cec_get_device_osd_name(cec_logical_address iAddress
)
360 retVal
.device
= iAddress
;
364 retVal
= cec_parser
->GetDeviceOSDName(iAddress
);
369 int cec_enable_physical_address_detection(void)
371 return cec_parser
? (cec_parser
->EnablePhysicalAddressDetection() ? 1 : 0) : -1;
374 int cec_set_stream_path_logical(CEC::cec_logical_address iAddress
)
376 return cec_parser
? (cec_parser
->SetStreamPath(iAddress
) ? 1 : 0) : -1;
379 int cec_set_stream_path_physical(uint16_t iPhysicalAddress
)
381 return cec_parser
? (cec_parser
->SetStreamPath(iPhysicalAddress
) ? 1 : 0) : -1;
384 cec_logical_addresses
cec_get_logical_addresses(void)
386 cec_logical_addresses addr
;
389 addr
= cec_parser
->GetLogicalAddresses();
393 int cec_get_current_configuration(libcec_configuration
*configuration
)
395 return cec_parser
? (cec_parser
->GetCurrentConfiguration(configuration
) ? 1 : 0) : -1;
398 int cec_can_persist_configuration(void)
400 return cec_parser
? (cec_parser
->CanPersistConfiguration() ? 1 : 0) : -1;
403 int persist_configuration(libcec_configuration
*configuration
)
405 return cec_parser
? (cec_parser
->PersistConfiguration(configuration
) ? 1 : 0) : -1;