2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2013 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/
41 * C interface implementation
44 ICECAdapter
*cec_parser
;
46 int cec_initialise(libcec_configuration
*configuration
)
48 cec_parser
= (ICECAdapter
*) CECInitialise(configuration
);
49 return (cec_parser
!= NULL
) ? 1 : 0;
52 void cec_destroy(void)
55 CECDestroy(cec_parser
);
59 int cec_open(const char *strPort
, uint32_t iTimeout
)
62 return cec_parser
->Open(strPort
, iTimeout
);
72 int cec_enable_callbacks(void *cbParam
, ICECCallbacks
*callbacks
)
75 return cec_parser
->EnableCallbacks(cbParam
, callbacks
) ? 1 : 0;
79 int8_t cec_find_adapters(cec_adapter
*deviceList
, uint8_t iBufSize
, const char *strDevicePath
/* = NULL */)
82 return cec_parser
->FindAdapters(deviceList
, iBufSize
, strDevicePath
);
86 int cec_ping_adapters(void)
89 return cec_parser
->PingAdapter() ? 1 : 0;
93 int cec_start_bootloader(void)
96 return cec_parser
->StartBootloader() ? 1 : 0;
100 int cec_transmit(const CEC::cec_command
*data
)
103 return cec_parser
->Transmit(*data
) ? 1 : 0;
107 int cec_set_logical_address(cec_logical_address iLogicalAddress
/* = CECDEVICE_PLAYBACKDEVICE1 */)
110 return cec_parser
->SetLogicalAddress(iLogicalAddress
) ? 1 : 0;
114 int cec_set_physical_address(uint16_t iPhysicalAddress
/* = CEC_DEFAULT_PHYSICAL_ADDRESS */)
117 return cec_parser
->SetPhysicalAddress(iPhysicalAddress
) ? 1 : 0;
121 int cec_power_on_devices(cec_logical_address address
/* = CECDEVICE_TV */)
124 return cec_parser
->PowerOnDevices(address
) ? 1 : 0;
128 int cec_standby_devices(cec_logical_address address
/* = CECDEVICE_BROADCAST */)
131 return cec_parser
->StandbyDevices(address
) ? 1 : 0;
135 int cec_set_active_source(cec_device_type type
)
138 return cec_parser
->SetActiveSource(type
) ? 1 : 0;
142 int cec_set_deck_control_mode(cec_deck_control_mode mode
, int bSendUpdate
) {
144 return cec_parser
->SetDeckControlMode(mode
, bSendUpdate
== 1) ? 1 : 0;
148 int cec_set_deck_info(cec_deck_info info
, int bSendUpdate
) {
150 return cec_parser
->SetDeckInfo(info
, bSendUpdate
== 1) ? 1 : 0;
155 int cec_set_inactive_view(void)
158 return cec_parser
->SetInactiveView() ? 1 : 0;
162 int cec_set_menu_state(cec_menu_state state
, int bSendUpdate
) {
164 return cec_parser
->SetMenuState(state
, bSendUpdate
== 1) ? 1 : 0;
168 int cec_set_osd_string(cec_logical_address iLogicalAddress
, cec_display_control duration
, const char *strMessage
)
171 return cec_parser
->SetOSDString(iLogicalAddress
, duration
, strMessage
) ? 1 : 0;
175 int cec_switch_monitoring(int bEnable
)
178 return cec_parser
->SwitchMonitoring(bEnable
== 1) ? 1 : 0;
182 cec_version
cec_get_device_cec_version(cec_logical_address iLogicalAddress
)
185 return cec_parser
->GetDeviceCecVersion(iLogicalAddress
);
186 return CEC_VERSION_UNKNOWN
;
189 int cec_get_device_menu_language(cec_logical_address iLogicalAddress
, cec_menu_language
*language
)
192 return cec_parser
->GetDeviceMenuLanguage(iLogicalAddress
, language
) ? 1 : 0;
196 uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress
)
199 return cec_parser
->GetDeviceVendorId(iLogicalAddress
);
203 uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress
)
206 return cec_parser
->GetDevicePhysicalAddress(iLogicalAddress
);
210 cec_logical_address
cec_get_active_source(void)
213 return cec_parser
->GetActiveSource();
214 return CECDEVICE_UNKNOWN
;
217 int cec_is_active_source(cec_logical_address iAddress
)
220 return cec_parser
->IsActiveSource(iAddress
);
224 cec_power_status
cec_get_device_power_status(cec_logical_address iLogicalAddress
)
227 return cec_parser
->GetDevicePowerStatus(iLogicalAddress
);
228 return CEC_POWER_STATUS_UNKNOWN
;
231 int cec_poll_device(cec_logical_address iLogicalAddress
)
234 return cec_parser
->PollDevice(iLogicalAddress
) ? 1 : 0;
238 cec_logical_addresses
cec_get_active_devices(void)
240 cec_logical_addresses addresses
;
243 addresses
= cec_parser
->GetActiveDevices();
247 int cec_is_active_device(cec_logical_address iAddress
)
250 return cec_parser
->IsActiveDevice(iAddress
) ? 1 : 0;
254 int cec_is_active_device_type(cec_device_type type
)
257 return cec_parser
->IsActiveDeviceType(type
) ? 1 : 0;
261 int cec_set_hdmi_port(cec_logical_address iBaseDevice
, uint8_t iPort
)
264 return cec_parser
->SetHDMIPort(iBaseDevice
, iPort
) ? 1 : 0;
268 int cec_volume_up(int bSendRelease
)
271 return cec_parser
->VolumeUp(bSendRelease
== 1);
275 int cec_volume_down(int bSendRelease
)
278 return cec_parser
->VolumeDown(bSendRelease
== 1);
282 int cec_mute_audio(int bSendRelease
)
285 return cec_parser
->MuteAudio(bSendRelease
== 1);
289 int cec_send_keypress(cec_logical_address iDestination
, cec_user_control_code key
, int bWait
)
292 return cec_parser
->SendKeypress(iDestination
, key
, bWait
== 1) ? 1 : 0;
296 int cec_send_key_release(cec_logical_address iDestination
, int bWait
)
299 return cec_parser
->SendKeyRelease(iDestination
, bWait
== 1) ? 1 : 0;
303 cec_osd_name
cec_get_device_osd_name(cec_logical_address iAddress
)
306 retVal
.device
= iAddress
;
310 retVal
= cec_parser
->GetDeviceOSDName(iAddress
);
315 int cec_set_stream_path_logical(CEC::cec_logical_address iAddress
)
317 return cec_parser
? (cec_parser
->SetStreamPath(iAddress
) ? 1 : 0) : -1;
320 int cec_set_stream_path_physical(uint16_t iPhysicalAddress
)
322 return cec_parser
? (cec_parser
->SetStreamPath(iPhysicalAddress
) ? 1 : 0) : -1;
325 cec_logical_addresses
cec_get_logical_addresses(void)
327 cec_logical_addresses addr
;
330 addr
= cec_parser
->GetLogicalAddresses();
334 int cec_get_current_configuration(libcec_configuration
*configuration
)
336 return cec_parser
? (cec_parser
->GetCurrentConfiguration(configuration
) ? 1 : 0) : -1;
339 int cec_can_persist_configuration(void)
341 return cec_parser
? (cec_parser
->CanPersistConfiguration() ? 1 : 0) : -1;
344 int cec_persist_configuration(libcec_configuration
*configuration
)
346 return cec_parser
? (cec_parser
->PersistConfiguration(configuration
) ? 1 : 0) : -1;
349 int cec_set_configuration(libcec_configuration
*configuration
)
351 return cec_parser
? (cec_parser
->SetConfiguration(configuration
) ? 1 : 0) : -1;
354 void cec_rescan_devices(void)
357 cec_parser
->RescanActiveDevices();
360 int cec_is_libcec_active_source(void)
362 return cec_parser
? (cec_parser
->IsLibCECActiveSource() ? 1 : 0) : -1;
365 int cec_get_device_information(const char *strPort
, CEC::libcec_configuration
*config
, uint32_t iTimeoutMs
)
367 return cec_parser
? (cec_parser
->GetDeviceInformation(strPort
, config
, iTimeoutMs
) ? 1 : 0) : -1;
370 const char * cec_get_lib_info(void)
372 return cec_parser
? cec_parser
->GetLibInfo() : NULL
;
375 void cec_init_video_standalone(void)
378 cec_parser
->InitVideoStandalone();
381 uint16_t cec_get_adapter_vendor_id(void)
383 return cec_parser
? cec_parser
->GetAdapterVendorId() : 0;
386 uint16_t cec_get_adapter_product_id(void)
388 return cec_parser
? cec_parser
->GetAdapterProductId() : 0;
391 uint8_t cec_audio_toggle_mute(void)
393 return cec_parser
? cec_parser
->AudioToggleMute() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
396 uint8_t cec_audio_mute(void)
398 return cec_parser
? cec_parser
->AudioMute() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
401 uint8_t cec_audio_unmute(void)
403 return cec_parser
? cec_parser
->AudioUnmute() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
406 uint8_t cec_audio_get_status(void)
408 return cec_parser
? cec_parser
->AudioStatus() : (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN
;
411 int8_t cec_detect_adapters(cec_adapter_descriptor
*deviceList
, uint8_t iBufSize
, const char *strDevicePath
, int bQuickScan
)
414 return cec_parser
->DetectAdapters(deviceList
, iBufSize
, strDevicePath
, bQuickScan
== 1);