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