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