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