cec: moved TransmitDeckStatus() to CCECPlaybackDevice
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
CommitLineData
e9de9629
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
33#include "CECBusDevice.h"
eafa9d46
LOK
34#include "../CECProcessor.h"
35#include "../implementations/ANCommandHandler.h"
36#include "../implementations/CECCommandHandler.h"
37#include "../implementations/SLCommandHandler.h"
11621576 38#include "../implementations/VLCommandHandler.h"
eafa9d46 39#include "../platform/timeutils.h"
e9de9629
LOK
40
41using namespace CEC;
42
43CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogicalAddress, uint16_t iPhysicalAddress) :
44 m_iPhysicalAddress(iPhysicalAddress),
9dc04b07 45 m_iStreamPath(0),
e9de9629 46 m_iLogicalAddress(iLogicalAddress),
e55f3f70 47 m_powerStatus(CEC_POWER_STATUS_UNKNOWN),
e9de9629 48 m_processor(processor),
1844f5f7 49 m_bMenuActive(true),
8747dd4f 50 m_bActiveSource(false),
0ab58650 51 m_iVendorClass(CEC_VENDOR_UNKNOWN),
d54e8570 52 m_iLastCommandSent(0),
6a1c0009 53 m_iLastActive(0),
5e822b09 54 m_cecVersion(CEC_VERSION_UNKNOWN)
e9de9629
LOK
55{
56 m_handler = new CCECCommandHandler(this);
51b2a094 57
a3269a0a
LOK
58 for (unsigned int iPtr = 0; iPtr < 4; iPtr++)
59 m_menuLanguage.language[iPtr] = '?';
60 m_menuLanguage.language[3] = 0;
61 m_menuLanguage.device = iLogicalAddress;
1fcf5a3f 62
51b2a094
LOK
63 m_vendor.vendor = CEC_VENDOR_UNKNOWN;
64 m_type = CEC_DEVICE_TYPE_RESERVED;
62f5527d 65 m_strDeviceName = CCECCommandHandler::ToString(m_iLogicalAddress);
e9de9629
LOK
66}
67
68CCECBusDevice::~CCECBusDevice(void)
69{
6a1c0009 70 m_condition.Broadcast();
e9de9629
LOK
71 delete m_handler;
72}
73
93729720 74void CCECBusDevice::AddLog(cec_log_level level, const CStdString &strMessage)
e9de9629 75{
93729720 76 m_processor->AddLog(level, strMessage);
e9de9629
LOK
77}
78
93729720 79bool CCECBusDevice::HandleCommand(const cec_command &command)
f8513317 80{
93729720
LOK
81 CLockObject lock(&m_mutex);
82 m_iLastActive = GetTimeMs();
83 m_handler->HandleCommand(command);
84 m_condition.Signal();
85 return true;
86}
87
88void CCECBusDevice::PollVendorId(void)
89{
90 CLockObject lock(&m_mutex);
91 if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST &&
92 m_vendor.vendor == CEC_VENDOR_UNKNOWN &&
d54e8570 93 GetTimeMs() - m_iLastCommandSent > 5000 &&
315ff809 94 !m_processor->IsMonitoring())
93729720 95 {
5e822b09 96 CStdString strLog;
62f5527d 97 strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 98 AddLog(CEC_LOG_NOTICE, strLog);
d54e8570 99 m_iLastCommandSent = GetTimeMs();
93729720
LOK
100
101 cec_command command;
102 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
103 if (m_processor->Transmit(command))
104 m_condition.Wait(&m_mutex, 1000);
105 }
106}
107
108bool CCECBusDevice::PowerOn(void)
109{
f437e4be
LOK
110 cec_power_status current = GetPowerStatus();
111 if (current != CEC_POWER_STATUS_ON &&
112 current != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
113 {
114 CStdString strLog;
115 strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
116 AddLog(CEC_LOG_DEBUG, strLog.c_str());
93729720 117
f437e4be 118 SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
93729720 119
f437e4be
LOK
120 cec_command command;
121 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
122
123 return m_processor->Transmit(command);
124 }
125
126 return true;
93729720
LOK
127}
128
129bool CCECBusDevice::Standby(void)
130{
131 CStdString strLog;
62f5527d 132 strLog.Format("<< putting '%s' (%X) in standby mode", GetLogicalAddressName(), m_iLogicalAddress);
93729720
LOK
133 AddLog(CEC_LOG_DEBUG, strLog.c_str());
134
135 cec_command command;
136 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY);
137
138 return m_processor->Transmit(command);
139}
140
141/** @name Getters */
142//@{
d7be392a 143cec_version CCECBusDevice::GetCecVersion(void)
93729720 144{
d7be392a 145 if (m_cecVersion == CEC_VERSION_UNKNOWN)
93729720 146 {
d7be392a
LOK
147 if (!MyLogicalAddressContains(m_iLogicalAddress))
148 {
5e822b09 149 CStdString strLog;
62f5527d 150 strLog.Format("<< requesting CEC version of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 151 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a
LOK
152 cec_command command;
153 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_CEC_VERSION);
154 CLockObject lock(&m_mutex);
155 if (m_processor->Transmit(command))
156 m_condition.Wait(&m_mutex, 1000);
157 }
93729720
LOK
158 }
159
160 return m_cecVersion;
161}
162
62f5527d
LOK
163const char* CCECBusDevice::GetLogicalAddressName(void) const
164{
165 return CCECCommandHandler::ToString(m_iLogicalAddress);
166}
167
d7be392a 168cec_menu_language &CCECBusDevice::GetMenuLanguage(void)
93729720 169{
d7be392a 170 if (!strcmp(m_menuLanguage.language, "???"))
93729720 171 {
d7be392a
LOK
172 if (!MyLogicalAddressContains(m_iLogicalAddress))
173 {
5e822b09 174 CStdString strLog;
62f5527d 175 strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 176 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a
LOK
177 cec_command command;
178 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GET_MENU_LANGUAGE);
179 CLockObject lock(&m_mutex);
180 if (m_processor->Transmit(command))
181 m_condition.Wait(&m_mutex, 1000);
182 }
93729720
LOK
183 }
184
185 return m_menuLanguage;
186}
187
188cec_logical_address CCECBusDevice::GetMyLogicalAddress(void) const
189{
190 return m_processor->GetLogicalAddress();
f8513317
LOK
191}
192
e9de9629
LOK
193uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const
194{
195 return m_processor->GetPhysicalAddress();
196}
197
d7be392a 198cec_power_status CCECBusDevice::GetPowerStatus(void)
e9de9629 199{
d7be392a 200 if (m_powerStatus == CEC_POWER_STATUS_UNKNOWN)
93729720 201 {
d7be392a
LOK
202 if (!MyLogicalAddressContains(m_iLogicalAddress))
203 {
5e822b09 204 CStdString strLog;
62f5527d 205 strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 206 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a
LOK
207 cec_command command;
208 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS);
209 CLockObject lock(&m_mutex);
210 if (m_processor->Transmit(command))
211 m_condition.Wait(&m_mutex, 1000);
212 }
93729720
LOK
213 }
214
215 return m_powerStatus;
e9de9629
LOK
216}
217
93729720 218const cec_vendor &CCECBusDevice::GetVendor(void)
a3269a0a 219{
93729720 220 if (m_vendor.vendor == CEC_VENDOR_UNKNOWN)
a3269a0a 221 {
d7be392a
LOK
222 if (!MyLogicalAddressContains(m_iLogicalAddress))
223 {
5e822b09 224 CStdString strLog;
62f5527d 225 strLog.Format("<< requesting vendor ID of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
5e822b09 226 AddLog(CEC_LOG_NOTICE, strLog);
d7be392a
LOK
227 cec_command command;
228 cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
229 CLockObject lock(&m_mutex);
93729720 230
d7be392a
LOK
231 if (m_processor->Transmit(command))
232 m_condition.Wait(&m_mutex, 1000);
233 }
a3269a0a 234 }
93729720
LOK
235
236 return m_vendor;
237}
238
239bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
240{
241 return m_processor->HasLogicalAddress(address);
a3269a0a
LOK
242}
243
93729720
LOK
244//@}
245
246/** @name Setters */
247//@{
e55f3f70 248void CCECBusDevice::SetCecVersion(const cec_version newVersion)
6a1c0009
LOK
249{
250 CStdString strLog;
251 m_cecVersion = newVersion;
252
253 switch (newVersion)
254 {
255 case CEC_VERSION_1_2:
62f5527d 256 strLog.Format("%s (%X): CEC version 1.2", GetLogicalAddressName(), m_iLogicalAddress);
6a1c0009
LOK
257 break;
258 case CEC_VERSION_1_2A:
62f5527d 259 strLog.Format("%s (%X): CEC version 1.2a", GetLogicalAddressName(), m_iLogicalAddress);
6a1c0009
LOK
260 break;
261 case CEC_VERSION_1_3:
62f5527d 262 strLog.Format("%s (%X): CEC version 1.3", GetLogicalAddressName(), m_iLogicalAddress);
6a1c0009
LOK
263 break;
264 case CEC_VERSION_1_3A:
62f5527d 265 strLog.Format("%s (%X): CEC version 1.3a", GetLogicalAddressName(), m_iLogicalAddress);
6a1c0009
LOK
266 break;
267 default:
62f5527d 268 strLog.Format("%s (%X): unknown CEC version", GetLogicalAddressName(), m_iLogicalAddress);
6a1c0009
LOK
269 m_cecVersion = CEC_VERSION_UNKNOWN;
270 break;
271 }
272 AddLog(CEC_LOG_DEBUG, strLog);
273}
274
93729720
LOK
275void CCECBusDevice::SetMenuLanguage(const cec_menu_language &language)
276{
277 if (language.device == m_iLogicalAddress)
278 {
279 CStdString strLog;
62f5527d 280 strLog.Format(">> %s (%X): menu language set to '%s'", GetLogicalAddressName(), m_iLogicalAddress, language.language);
93729720
LOK
281 m_processor->AddLog(CEC_LOG_DEBUG, strLog);
282 m_menuLanguage = language;
283 }
284}
285
9dc04b07 286void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
93729720
LOK
287{
288 if (iNewAddress > 0)
289 {
290 CStdString strLog;
62f5527d 291 strLog.Format(">> %s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
93729720
LOK
292 AddLog(CEC_LOG_DEBUG, strLog.c_str());
293
294 m_iPhysicalAddress = iNewAddress;
295 }
296}
297
9dc04b07
LOK
298void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */)
299{
300 if (iNewAddress > 0)
301 {
302 CStdString strLog;
62f5527d 303 strLog.Format(">> %s (%X): stream path changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, iOldAddress, iNewAddress);
9dc04b07
LOK
304 AddLog(CEC_LOG_DEBUG, strLog.c_str());
305
306 m_iStreamPath = iNewAddress;
96274140
LOK
307
308 if (iNewAddress > 0)
309 SetPowerStatus(CEC_POWER_STATUS_ON);
9dc04b07
LOK
310 }
311}
312
e55f3f70
LOK
313void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
314{
b0271d54
LOK
315 if (m_powerStatus != powerStatus)
316 {
317 CStdString strLog;
62f5527d 318 strLog.Format(">> %s (%X): power status changed from %2x to %2x", GetLogicalAddressName(), m_iLogicalAddress, m_powerStatus, powerStatus);
b0271d54
LOK
319 m_processor->AddLog(CEC_LOG_DEBUG, strLog);
320 m_powerStatus = powerStatus;
321 }
e55f3f70
LOK
322}
323
2cd8b5d0 324void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */)
e9de9629 325{
0500da96 326 m_vendor.vendor = (cec_vendor_id)iVendorId;
e9de9629
LOK
327 m_iVendorClass = iVendorClass;
328
329 switch (iVendorId)
330 {
331 case CEC_VENDOR_SAMSUNG:
0ab58650
LOK
332 if (m_handler->GetVendorId() != CEC_VENDOR_SAMSUNG)
333 {
334 delete m_handler;
335 m_handler = new CANCommandHandler(this);
336 }
e9de9629
LOK
337 break;
338 case CEC_VENDOR_LG:
0ab58650
LOK
339 if (m_handler->GetVendorId() != CEC_VENDOR_LG)
340 {
341 delete m_handler;
342 m_handler = new CSLCommandHandler(this);
343 }
e9de9629 344 break;
11621576
LOK
345 case CEC_VENDOR_PANASONIC:
346 if (m_handler->GetVendorId() != CEC_VENDOR_PANASONIC)
347 {
348 delete m_handler;
349 m_handler = new CVLCommandHandler(this);
350 }
351 break;
e9de9629 352 default:
0ab58650
LOK
353 if (m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN)
354 {
355 delete m_handler;
356 m_handler = new CCECCommandHandler(this);
357 }
e9de9629
LOK
358 break;
359 }
360
361 CStdString strLog;
62f5527d 362 strLog.Format("%s (%X): vendor = %s (%06x) class = %2x", GetLogicalAddressName(), m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass());
e9de9629
LOK
363 m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
364}
93729720 365//@}
e9de9629 366
93729720
LOK
367/** @name Transmit methods */
368//@{
369bool CCECBusDevice::TransmitActiveSource(void)
0f23c85c 370{
8747dd4f
LOK
371 if (m_bActiveSource)
372 {
373 CStdString strLog;
62f5527d 374 strLog.Format("<< %s (%X) -> broadcast (F): active source (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
8747dd4f 375 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c 376
8747dd4f
LOK
377 cec_command command;
378 cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
379 command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
380 command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
0f23c85c 381
8747dd4f
LOK
382 return m_processor->Transmit(command);
383 }
384 else
385 {
386 CStdString strLog;
62f5527d 387 strLog.Format("<< %s (%X) is not the active source", GetLogicalAddressName(), m_iLogicalAddress);
8747dd4f
LOK
388 AddLog(CEC_LOG_DEBUG, strLog);
389 }
390
391 return false;
0f23c85c
LOK
392}
393
93729720 394bool CCECBusDevice::TransmitActiveView(void)
0f23c85c 395{
d7be392a 396 CStdString strLog;
62f5527d 397 strLog.Format("<< %s (%X) -> broadcast (F): active view (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
d7be392a 398 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c
LOK
399
400 cec_command command;
93729720
LOK
401 cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
402 command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
403 command.parameters.push_back(m_iPhysicalAddress & 0xFF);
0f23c85c
LOK
404
405 return m_processor->Transmit(command);
406}
407
29912296 408bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest)
0f23c85c 409{
d7be392a 410 CStdString strLog;
62f5527d 411 strLog.Format("<< %s (%X) -> %s (%X): cec version ", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
d7be392a
LOK
412 switch (m_cecVersion)
413 {
414 case CEC_VERSION_1_2:
415 strLog.append("1.2");
416 break;
417 case CEC_VERSION_1_2A:
418 strLog.append("1.2a");
419 break;
420 case CEC_VERSION_1_3:
421 strLog.append("1.3");
422 break;
423 case CEC_VERSION_1_3A:
424 strLog.append("1.3a");
425 break;
426 default:
427 strLog.append("unknown");
428 break;
429 }
430 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c
LOK
431
432 cec_command command;
f8513317 433 cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_CEC_VERSION);
700c1ea7 434 command.parameters.push_back(m_cecVersion);
0f23c85c
LOK
435
436 return m_processor->Transmit(command);
437}
438
93729720
LOK
439bool CCECBusDevice::TransmitInactiveView(void)
440{
d7be392a 441 CStdString strLog;
62f5527d 442 strLog.Format("<< %s (%X) -> broadcast (F): inactive view", GetLogicalAddressName(), m_iLogicalAddress);
d7be392a 443 AddLog(CEC_LOG_NOTICE, strLog);
93729720
LOK
444
445 cec_command command;
446 cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE);
447 command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
448 command.parameters.push_back(m_iPhysicalAddress & 0xFF);
449
450 return m_processor->Transmit(command);
451}
452
29912296 453bool CCECBusDevice::TransmitMenuState(cec_logical_address dest)
0f23c85c 454{
d7be392a 455 CStdString strLog;
62f5527d 456 strLog.Format("<< %s (%X) -> %s (%X): ", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
1844f5f7 457 if (m_bMenuActive)
d7be392a 458 strLog.append("menu active");
0f23c85c 459 else
d7be392a
LOK
460 strLog.append("menu inactive");
461 AddLog(CEC_LOG_NOTICE, strLog);
0f23c85c
LOK
462
463 cec_command command;
f8513317 464 cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_MENU_STATUS);
1844f5f7 465 command.parameters.push_back(m_bMenuActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
0f23c85c
LOK
466
467 return m_processor->Transmit(command);
468}
469
29912296 470bool CCECBusDevice::TransmitOSDName(cec_logical_address dest)
0f23c85c 471{
0f23c85c 472 CStdString strLog;
62f5527d 473 strLog.Format("<< %s (%X) -> %s (%X): OSD name '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest, m_strDeviceName.c_str());
0f23c85c
LOK
474 AddLog(CEC_LOG_NOTICE, strLog.c_str());
475
476 cec_command command;
f8513317 477 cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_NAME);
787a3cb8
LOK
478 for (unsigned int iPtr = 0; iPtr < m_strDeviceName.length(); iPtr++)
479 command.parameters.push_back(m_strDeviceName.at(iPtr));
0f23c85c
LOK
480
481 return m_processor->Transmit(command);
482}
483
38bdb943
LOK
484bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage)
485{
486 CStdString strLog;
62f5527d 487 strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest, strMessage);
38bdb943
LOK
488 AddLog(CEC_LOG_NOTICE, strLog.c_str());
489
490 cec_command command;
491 cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_SET_OSD_STRING);
492 command.parameters.push_back((uint8_t)duration);
493
494 unsigned int iLen = strlen(strMessage);
495 if (iLen > 13) iLen = 13;
496
497 for (unsigned int iPtr = 0; iPtr < iLen; iPtr++)
498 command.parameters.push_back(strMessage[iPtr]);
499
500 return m_processor->Transmit(command);
501}
502
29912296 503bool CCECBusDevice::TransmitPhysicalAddress(void)
0f23c85c
LOK
504{
505 CStdString strLog;
62f5527d 506 strLog.Format("<< %s (%X) -> broadcast (F): physical adddress %4x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
0f23c85c
LOK
507 AddLog(CEC_LOG_NOTICE, strLog.c_str());
508
509 cec_command command;
f8513317 510 cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
0f23c85c
LOK
511 command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
512 command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
6fc97923 513 command.parameters.push_back((uint8_t) (m_type));
0f23c85c
LOK
514
515 return m_processor->Transmit(command);
516}
517
93729720 518bool CCECBusDevice::TransmitPoll(cec_logical_address dest)
57f45e6c
LOK
519{
520 bool bReturn(false);
521
93729720
LOK
522 if (dest == CECDEVICE_UNKNOWN)
523 dest = m_iLogicalAddress;
f8513317 524
57f45e6c 525 CStdString strLog;
62f5527d 526 strLog.Format("<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
d7be392a 527 AddLog(CEC_LOG_NOTICE, strLog.c_str());
57f45e6c
LOK
528
529 cec_command command;
93729720 530 cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_NONE);
57f45e6c
LOK
531 CLockObject lock(&m_mutex);
532
533 bReturn = m_processor->Transmit(command);
534 AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
535 return bReturn;
536}
93729720
LOK
537
538bool CCECBusDevice::TransmitPowerState(cec_logical_address dest)
539{
540 CStdString strLog;
62f5527d 541 strLog.Format("<< %s (%X) -> %s (%X): ", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
d7be392a
LOK
542
543 switch (m_powerStatus)
544 {
545 case CEC_POWER_STATUS_ON:
546 strLog.append("powered on");
547 break;
548 case CEC_POWER_STATUS_STANDBY:
549 strLog.append("in standby mode");
550 break;
551 case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY:
552 strLog.append("in transition from on to standby");
553 break;
554 case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON:
555 strLog.append("in transition from standby to on");
556 break;
557 default:
558 strLog.append("power state unknown");
559 break;
560 }
561 AddLog(CEC_LOG_NOTICE, strLog.c_str());
562
93729720
LOK
563 strLog.Format("<< reporting power status '%d'", m_powerStatus);
564 AddLog(CEC_LOG_NOTICE, strLog);
565
566 cec_command command;
567 cec_command::format(command, m_iLogicalAddress, dest, CEC_OPCODE_REPORT_POWER_STATUS);
568 command.parameters.push_back((uint8_t) m_powerStatus);
569
570 return m_processor->Transmit(command);
571}
572
573bool CCECBusDevice::TransmitVendorID(cec_logical_address dest)
574{
d7be392a 575 CStdString strLog;
62f5527d 576 strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
d7be392a
LOK
577 AddLog(CEC_LOG_NOTICE, strLog);
578
93729720
LOK
579 m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
580 return false;
581}
582//@}