Ticket #11524: power.patch
File power.patch, 10.7 KB (added by , 11 years ago) |
---|
-
mythtv/libs/libmythtv/recorders/channelbase.cpp
commit ea5e27ad32d6a72f58783e1e7ec12d75d48b7249 Author: Rick Scott <rwscott@users.sourceforge.net> Date: Sat May 4 07:10:47 2013 -0400 Support power save mode with the Internal Firewire channel change with analog capture. Expand on d49f3f22d by adding support for EnterPowerSavingMode, allowing the firewire device to be powered off when not in use. Also avoids spinning up the port handler thread when only changing channels. diff --git a/mythtv/libs/libmythtv/recorders/channelbase.cpp b/mythtv/libs/libmythtv/recorders/channelbase.cpp index 35544fc..7c729e5 100644
a b using namespace std; 17 17 #include <QCoreApplication> 18 18 19 19 // MythTV headers 20 #ifdef USING_OSX_FIREWIRE21 #include "darwinfirewiredevice.h"22 #endif23 #ifdef USING_LINUX_FIREWIRE24 #include "linuxfirewiredevice.h"25 #endif26 20 #include "firewirechannel.h" 27 21 #include "mythcorecontext.h" 28 22 #include "cetonchannel.h" … … void ChannelBase::HandleScript(const QString &freqid) 700 694 } 701 695 else 702 696 { 703 if ((*it)->externalChanger.toLower() == "internal") 704 { 705 ok = ChangeInternalChannel(freqid, (*it)->inputid); 706 if (!ok) 707 { 708 LOG(VB_GENERAL, LOG_ERR, LOC + "Can not execute internal channel " 709 "changer."); 710 m_system_status = 2; // failed 711 } 712 else 713 m_system_status = 3; // success 714 715 HandleScriptEnd(ok); 716 } 717 else 718 { 719 ok = ChangeExternalChannel((*it)->externalChanger, freqid); 720 if (!ok) 721 { 722 LOG(VB_GENERAL, LOG_ERR, LOC + "Can not execute channel changer."); 723 m_system_status = 2; // failed 724 HandleScriptEnd(ok); 725 } 726 } 727 } 728 } 729 730 bool ChannelBase::ChangeInternalChannel(const QString &freqid, 731 uint inputid) 732 { 733 #ifdef USING_FIREWIRE 734 FirewireDevice *device = NULL; 735 QString fwnode = CardUtil::GetFirewireChangerNode(inputid); 736 uint64_t guid = string_to_guid(fwnode); 737 QString fwmodel = CardUtil::GetFirewireChangerModel(inputid); 738 739 LOG(VB_GENERAL, LOG_ERR, LOC + QString("Internal channel change to %1 " 740 "on inputid %2, GUID %3 (%4)").arg(freqid).arg(inputid) 741 .arg(fwnode).arg(fwmodel)); 742 743 #ifdef USING_LINUX_FIREWIRE 744 device = new LinuxFirewireDevice( 745 guid, 0, 100, 1); 746 #endif // USING_LINUX_FIREWIRE 747 748 #ifdef USING_OSX_FIREWIRE 749 device = new DarwinFirewireDevice(guid, 0, 100); 750 #endif // USING_OSX_FIREWIRE 751 752 if (!device) 753 return false; 754 755 if (!device->OpenPort()) 756 return false; 757 758 if (!device->SetChannel(fwmodel, 0, freqid.toUInt())) 759 { 760 device->ClosePort(); 761 delete device; 762 device = NULL; 763 return false; 697 ok = ChangeExternalChannel((*it)->externalChanger, freqid); 698 if (!ok) 699 { 700 LOG(VB_GENERAL, LOG_ERR, LOC + "Can not execute channel changer."); 701 m_system_status = 2; // failed 702 HandleScriptEnd(ok); 703 } 764 704 } 765 766 device->ClosePort();767 delete device;768 device = NULL;769 return true;770 #else771 return false;772 #endif773 705 } 774 706 775 707 /// \note m_system_lock must be held when this is called -
mythtv/libs/libmythtv/recorders/channelbase.h
diff --git a/mythtv/libs/libmythtv/recorders/channelbase.h b/mythtv/libs/libmythtv/recorders/channelbase.h index 5d87b13..751bd0f 100644
a b class ChannelBase 151 151 152 152 bool ChangeExternalChannel(const QString &changer, 153 153 const QString &newchan); 154 bool ChangeInternalChannel(const QString &newchan,155 uint cardinputid);156 154 157 155 TVRec *m_pParent; 158 156 QString m_curchannelname; -
mythtv/libs/libmythtv/recorders/dtvchannel.cpp
diff --git a/mythtv/libs/libmythtv/recorders/dtvchannel.cpp b/mythtv/libs/libmythtv/recorders/dtvchannel.cpp index 204f727..e6fa5f5 100644
a b 3 3 using namespace std; 4 4 5 5 // MythTV headers 6 #ifdef USING_OSX_FIREWIRE 7 #include "darwinfirewiredevice.h" 8 #endif 9 #ifdef USING_LINUX_FIREWIRE 10 #include "linuxfirewiredevice.h" 11 #endif 6 12 #include "mythdb.h" 7 13 #include "tv_rec.h" 8 14 #include "cardutil.h" … … void DTVChannel::ReturnMasterLock(DTVChannelP &chan) 175 181 } 176 182 } 177 183 184 bool DTVChannel::InternalTune(bool power, uint channel) 185 { 186 bool ok; 187 FirewireDevice *device = NULL; 188 QString fwnode = CardUtil::GetFirewireChangerNode(m_currentInputID); 189 uint64_t guid = string_to_guid(fwnode); 190 191 LOG(VB_CHANNEL, LOG_INFO, LOC + "Internal channel change"); 192 193 #ifdef USING_LINUX_FIREWIRE 194 device = new LinuxFirewireDevice(guid, 0, 100, 1); 195 #endif // USING_LINUX_FIREWIRE 196 197 #ifdef USING_OSX_FIREWIRE 198 device = new DarwinFirewireDevice(guid, 0, 100); 199 #endif // USING_OSX_FIREWIRE 200 if (device && device->OpenPort(false)) 201 { 202 ok = device->SetPowerState(power); 203 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("setting power state result %1").arg(ok)); 204 if (power) 205 { 206 QString fwmodel = CardUtil::GetFirewireChangerModel(m_currentInputID); 207 208 ok = device->SetChannel(fwmodel, 0, channel); 209 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("channel change result %1").arg(ok)); 210 } 211 m_system_status = ok ? 3 : 2; 212 device->ClosePort(); 213 delete device; 214 device = NULL; 215 } 216 else 217 { 218 LOG(VB_CHANNEL, LOG_ERR, LOC + "Opening firewire device port failed"); 219 m_system_status = 2; 220 ok = false; 221 } 222 return(ok); 223 } 224 178 225 bool DTVChannel::SetChannelByString(const QString &channum) 179 226 { 180 227 QString loc = LOC + QString("SetChannelByString(%1): ").arg(channum); … … bool DTVChannel::SetChannelByString(const QString &channum) 339 386 ok = Tune(freqid, finetune); 340 387 } 341 388 } 389 #ifdef USING_FIREWIRE 390 else if ((*it)->externalChanger.toLower() == "internal") 391 { 392 ok = InternalTune(true, freqid.toUInt()); 393 } 394 #endif 342 395 343 396 LOG(VB_CHANNEL, LOG_INFO, loc + ((ok) ? "success" : "failure")); 344 397 … … bool DTVChannel::SetChannelByString(const QString &channum) 401 454 m_pParent->SetVideoFiltersForChannel(GetCurrentSourceID(), channum); 402 455 InitPictureAttributes(); 403 456 404 HandleScript(freqid); 457 #ifdef USING_FIREWIRE 458 if ((*it)->externalChanger.toLower() != "internal") 459 #endif 460 { 461 HandleScript(freqid); 462 } 405 463 406 464 return ok; 407 465 } … … bool DTVChannel::TuneMultiplex(uint mplexid, QString inputname) 425 483 426 484 return Tune(tuning, inputname); 427 485 } 486 487 bool DTVChannel::EnterPowerSavingMode(void) 488 { 489 #ifdef USING_FIREWIRE 490 InternalTune(false, 0); 491 #endif 492 return true; 493 } -
mythtv/libs/libmythtv/recorders/dtvchannel.h
diff --git a/mythtv/libs/libmythtv/recorders/dtvchannel.h b/mythtv/libs/libmythtv/recorders/dtvchannel.h index 36bb2ad..c835a5b 100644
a b class DTVChannel : public ChannelBase 52 52 /// \brief Performs IPTV Tuning. Only implemented by IPTVChannel. 53 53 virtual bool Tune(const IPTVTuningData&) { return false; } 54 54 /// \brief Enters power saving mode if the card supports it 55 virtual bool EnterPowerSavingMode(void) 56 { 57 return true; 58 } 55 virtual bool EnterPowerSavingMode(void); 59 56 /// \brief This tunes on the frequency Identification parameter for 60 57 /// hardware that supports it. 61 58 /// … … class DTVChannel : public ChannelBase 134 131 void SetTuningMode(const QString &tuningmode); 135 132 136 133 void SaveCachedPids(const pid_cache_t &pid_cache) const; 134 bool InternalTune(bool power, uint channel); 137 135 138 136 protected: 139 137 /// \brief Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable -
mythtv/libs/libmythtv/recorders/firewiredevice.h
diff --git a/mythtv/libs/libmythtv/recorders/firewiredevice.h b/mythtv/libs/libmythtv/recorders/firewiredevice.h index 4151220..58841b2 100644
a b class FirewireDevice 194 194 195 195 // Commands 196 196 virtual bool OpenPort(void) = 0; 197 virtual bool OpenPort(bool allow_recording) = 0; 197 198 virtual bool ClosePort(void) = 0; 198 199 virtual bool ResetBus(void) { return false; } 199 200 -
mythtv/libs/libmythtv/recorders/linuxfirewiredevice.cpp
diff --git a/mythtv/libs/libmythtv/recorders/linuxfirewiredevice.cpp b/mythtv/libs/libmythtv/recorders/linuxfirewiredevice.cpp index 0fd86a2..bdf27bb 100644
a b void LinuxFirewireDevice::HandleBusReset(void) 235 235 } 236 236 } 237 237 238 bool LinuxFirewireDevice::OpenPort( void)238 bool LinuxFirewireDevice::OpenPort(bool allow_record) 239 239 { 240 if (allow_record) 241 { 240 242 LOG(VB_RECORD, LOG_INFO, LOC + "Starting Port Handler Thread"); 241 243 QMutexLocker locker(&m_priv->start_stop_port_handler_lock); 242 244 LOG(VB_RECORD, LOG_INFO, LOC + "Starting Port Handler Thread -- locked"); 245 } 243 246 244 247 LOG(VB_RECORD, LOG_INFO, LOC + "OpenPort()"); 245 248 … … bool LinuxFirewireDevice::OpenPort(void) 279 282 return false; 280 283 } 281 284 285 if (allow_record && !m_priv->port_handler_thread) 286 { 282 287 m_priv->run_port_handler = true; 283 288 284 289 LOG(VB_RECORD, LOG_INFO, LOC + "Starting port handler thread"); … … bool LinuxFirewireDevice::OpenPort(void) 289 294 m_priv->port_handler_wait.wait(mlocker.mutex(), 100); 290 295 291 296 LOG(VB_RECORD, LOG_INFO, LOC + "Port handler thread started"); 297 } 292 298 293 299 m_open_port_cnt++; 294 300 295 301 return true; 296 302 } 297 303 304 bool LinuxFirewireDevice::OpenPort(void) 305 { 306 return OpenPort(true); 307 } 308 298 309 bool LinuxFirewireDevice::ClosePort(void) 299 310 { 300 311 LOG(VB_RECORD, LOG_INFO, LOC + "Stopping Port Handler Thread"); … … bool LinuxFirewireDevice::ClosePort(void) 321 332 if (IsNodeOpen()) 322 333 CloseNode(); 323 334 335 if (m_priv->port_handler_thread) 336 { 324 337 LOG(VB_RECORD, LOG_INFO, 325 338 LOC + "Waiting for port handler thread to stop"); 326 339 m_priv->run_port_handler = false; … … bool LinuxFirewireDevice::ClosePort(void) 334 347 m_priv->port_handler_thread = NULL; 335 348 336 349 LOG(VB_RECORD, LOG_INFO, LOC + "Joined port handler thread"); 350 } 337 351 338 352 remove_handle(GetInfoPtr()->fw_handle); 339 353 -
mythtv/libs/libmythtv/recorders/linuxfirewiredevice.h
diff --git a/mythtv/libs/libmythtv/recorders/linuxfirewiredevice.h b/mythtv/libs/libmythtv/recorders/linuxfirewiredevice.h index ee1ca0f..36ae48f 100644
a b class LinuxFirewireDevice : public FirewireDevice, public QRunnable 29 29 30 30 // Commands 31 31 virtual bool OpenPort(void); 32 virtual bool OpenPort(bool allow_recording); 32 33 virtual bool ClosePort(void); 33 34 virtual bool ResetBus(void); 34 35